[Bug c++/29080] New: Multiple-inheritance code triggers "internal compiler error: in build_base_path, at cp/class.c:273"

2006-09-14 Thread raymond at corvil dot com
Compiling a .cpp file with the following contents triggers an internal compiler
error:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

struct Base {
template void  method() { }
};

struct Left : public Base { };
struct Right: public Base { };
struct Join : public Left, public Right { };

voidfunction()
{
Join join;
join.Base::method();
join.Left::method();
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Issued command-line:
g++ -Wall -W -Wundef -Wpointer-arith -g -O0 -c -o /dev/null bug.cpp

Resulting output:
bug.cpp: In function 'void function()':
bug.cpp:13: internal compiler error: in build_base_path, at cp/class.c:273
Please submit a full bug report,
...

The error does not occur if structs Left and Right inherit virtually from Base;
 that is, "struct Left : virtual public Base { };" and similarly for Right. 
The same error occurs with gcc-3.4.3, the only difference being that the
relevant line number in cp/class.cp is 275.

Full output from running with "-v --save-temps" is as follows:
g++ -v -save-temps -Wall -W -Wundef -Wpointer-arith -g -O0 -c -o /dev/null
bug.cpp
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1.1/configure --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
Thread model: posix
gcc version 4.1.1
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1plus -E -quiet -v
-D_GNU_SOURCE bug.cpp -mtune=pentiumpro -Wall -W -Wundef -Wpointer-arith
-fworking-directory -O0 -fpch-preprocess -o bug.ii
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1

/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/i686-pc-linux-gnu

/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/backward
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/include
 /usr/include
End of search list.
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1plus -fpreprocessed bug.ii
-quiet -dumpbase bug.cpp -mtune=pentiumpro -auxbase-strip /dev/null -g -O0
-Wall -W -Wundef -Wpointer-arith -version -o bug.s
GNU C++ version 4.1.1 (i686-pc-linux-gnu)
compiled by GNU C version 4.1.1.
GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=63424
Compiler executable checksum: 5c1ee95ea2451a4e1aafd30c10a207cb
bug.cpp: In function 'void function()':
bug.cpp:13: internal compiler error: in build_base_path, at cp/class.c:273
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Contents of bug.ii:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# 1 "bug.cpp"
# 1 "/home/raymond/tmp//"
# 1 ""
# 1 ""
# 1 "bug.cpp"

struct Base {
 template void method() { }
};

struct Left : public Base { };
struct Right : public Base { };
struct Join : public Left, public Right { };

void function()
{
 Join join;
 join.Base::method();
 join.Left::method();
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


-- 
   Summary: Multiple-inheritance code triggers "internal compiler
error: in build_base_path, at cp/class.c:273"
   Product: gcc
   Version: 4.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: raymond at corvil dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29080



[Bug c++/29080] [4.0/4.1/4.2 Regression] Multiple-inheritance with template method function code triggers "internal compiler error: in build_base_path, at cp/class.c:273"

2006-09-14 Thread raymond at corvil dot com


--- Comment #2 from raymond at corvil dot com  2006-09-14 15:58 ---
Line 13 in the sample code is invalid code but line 14 is valid (Base is an
unambiguous base class of Left).  Deleting line 13 leaves code that compiles
cleanly with gcc-3.3.5 (i386-portbld-freebsd4.8, gcc version 3.3.5 20040901
(prerelease) [FreeBSD]).

Apologies for any confusion, I meant to delete line 13 before submitting.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29080



[Bug c++/33012] New: ICE on throwing copy of object returned by reference from method with traits-deduced return-type

2007-08-07 Thread raymond at corvil dot com
iated from here
bug.cpp:79: internal compiler error: in stabilize_call, at cp/tree.c:2248
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


-- 
   Summary: ICE on throwing copy of object returned by reference
from method with traits-deduced return-type
   Product: gcc
   Version: 4.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: raymond at corvil dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33012



[Bug c++/33012] ICE on throwing copy of object returned by reference from method with traits-deduced return-type

2007-08-07 Thread raymond at corvil dot com


--- Comment #1 from raymond at corvil dot com  2007-08-07 17:59 ---
I have been able to reproduce the same ICE in 3.4.2,

gcc version 3.4.2 20040827 (prerelease) [FreeBSD]

but not in 2.95.4 or 4.1.2:

gcc version 2.95.4 20020320 [FreeBSD]
gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)


I originally found the ICE in some code that was throwing a copy of an object
in a std::vector on the stack.  By playing around with the test code I posted,
I found that it seems to trigger only when the following three conditions occur
together:

* the copy is directly thrown, and not when the a copy is declared on the stack
and then thrown;
* the method that provides the reference to be copied has a return-type deduced
from a traits template;
* the class of the object being thrown does not provide a copy-constructor.

I've tried to illustrate in the full test case that, if any one of these
conditions is false, then the ICE doesn't happen.


The following shorter test-case also triggers the error.  I know it includes a
standard header, and I haven't provided pre-processed sources for this, but
it's just for illustration purposes.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include 

/*
 * inner() throws a copy of an object contained in a vector.
 * It's templated to show what happens with different _Types.
 */

template
voidinner()
{
typename std::vector<_Type> vector(1);
throw _Type(*vector.begin());
}


struct Generated { };

struct Manual {
Manual() { }
Manual(const Manual&) { }
};


voidouter()
{
// No problems when the class has a hand-written copy-constructor:
inner();

// ICE when the class has a compiler-supplied copy-constructor:
inner();
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33012



[Bug c++/33012] ICE on throwing copy of object returned by reference from method with traits-deduced return-type

2007-08-16 Thread raymond at corvil dot com


--- Comment #3 from raymond at corvil dot com  2007-08-16 09:50 ---
Yes, it does not happen with recent releases.  I logged it because I couldn't
find any hint of this problem having been seen and noted anywhere.  I just
wanted to let you know about it in case the problem has simply been masked by
recent code changes rather than specifically fixed (not that I'm suggesting it
has ;-) I just don't know).  Thanks!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33012



[Bug c++/52662] New: ICE in replace_reg_with_saved_mem, at caller-save.c:1125

2012-03-21 Thread raymond at corvil dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52662

 Bug #: 52662
   Summary: ICE in replace_reg_with_saved_mem, at
caller-save.c:1125
Classification: Unclassified
   Product: gcc
   Version: 4.6.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: raym...@corvil.com


I made a small code-change, moving an assignment into the else-branch of an
if-statement, and this change triggered the ICE.  This is on a 64-bit system,
and only happens when compiling 32-bit code;  the same code doesn't trigger the
ICE in 64-bit mode.

I'm sorry I haven't been able to reduce this to a small test-case but even the
smallest code change makes all the difference.  Here is a diff showing the
change:

$ diff -U 7 okay.IpPkt.ii ICE.IpPkt.ii
--- okay.IpPkt.ii   2012-03-22 05:54:34.499872293 +
+++ ICE.IpPkt.ii2012-03-22 05:54:59.290872957 +
@@ -76207,16 +76207,16 @@
  template
  void merge(const _Type *data, size_t size = sizeof(_Type))
  {
   if( m_hash_width == HASH_WIDTH_0 ) {
const uint8_t *begin = reinterpret_cast<
const uint8_t *>(data);
m_data.insert(m_data.end(), begin, begin + size);
-  }
-  m_hash = Hashing::hash(m_hash, data, size);
+  } else
+   m_hash = Hashing::hash(m_hash, data, size);
  }


 protected:
  ShellGUID uintGUID(size_t width)
  {
   ( (void)0 );



I will attach the full pre-processed code for both the successful compilation
and for the ICE;  here is the output from "g++ -v":

$ g++ -v -save-temps  -m32 -g -O3  -fPIC -Wall -Wextra -W -Wundef
-Wpointer-arith -Wsign-promo -Woverloaded-virtual -Wreorder
-DARDEA_VERSION="\"r70118M\"" -I./lib/include -I./src  -I./lib/include -I./src
-c -o obj/plugins/IpPkt.o src/plugins/IpPkt.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /usr/Taw/tmp/gcc-4.6.1/configure --prefix=/usr
--libdir=/usr/lib64 --libexecdir=/usr/lib64 --disable-libstdcxx-pch
--enable-shared --enable-threads=posix --enable-clocale=gnu
--enable-__cxa_atexit --enable-languages=c,c++,fortran --enable-c99
--enable-long-long
Thread model: posix
gcc version 4.6.1 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-m32' '-g' '-O3' '-fPIC' '-Wall'
'-Wextra' '-Wundef' '-Wpointer-arith' '-Wsign-promo' '-Woverloaded-virtual'
'-Wreorder' '-D' 'ARDEA_VERSION="r70118M"' '-I' './lib/include' '-I' './src'
'-I' './lib/include' '-I' './src' '-c' '-o' 'obj/plugins/IpPkt.o'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/cc1plus -E -quiet -v -I
./lib/include -I ./src -I ./lib/include -I ./src -imultilib 32 -D_GNU_SOURCE -D
ARDEA_VERSION="r70118M" src/plugins/IpPkt.cpp -m32 -mtune=generic -march=x86-64
-Wall -Wextra -Wundef -Wpointer-arith -Wsign-promo -Woverloaded-virtual
-Wreorder -fPIC -g -fworking-directory -O3 -fpch-preprocess -o IpPkt.ii
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory "./lib/include"
ignoring duplicate directory "./src"
#include "..." search starts here:
#include <...> search starts here:
 ./lib/include
 ./src
 /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/../../../../include/c++/4.6.1

/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/../../../../include/c++/4.6.1/x86_64-unknown-linux-gnu/32

/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/../../../../include/c++/4.6.1/backward
 /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/include
 /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-m32' '-g' '-O3' '-fPIC' '-Wall'
'-Wextra' '-Wundef' '-Wpointer-arith' '-Wsign-promo' '-Woverloaded-virtual'
'-Wreorder' '-D' 'ARDEA_VERSION="r70118M"' '-I' './lib/include' '-I' './src'
'-I' './lib/include' '-I' './src' '-c' '-o' 'obj/plugins/IpPkt.o'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.6.1/cc1plus -fpreprocessed IpPkt.ii
-quiet -dumpbase IpPkt.cpp -m32 -mtune=generic -march=x86-64 -auxbase-strip
obj/plugins/IpPkt.o -g -O3 -Wall -Wextra -Wundef -Wpointer-arith -Wsign-promo
-Woverloaded-virtual -Wreorder -version -fPIC -o IpPkt.s
GNU C++ (GCC) version 4.6.1 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.1, GMP version 5.0.2, MPFR version 3.1.0, MPC
version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (GCC) version 4.6.1 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.1, GMP version 5.0.2, MPFR version 3.1.0, MPC
version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 65eaa1b8603a14c0584988a2c1fafc0e
src/plugins/IpPkt.cpp: In member fu

[Bug c++/52662] ICE in replace_reg_with_saved_mem, at caller-save.c:1125

2012-03-21 Thread raymond at corvil dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52662

--- Comment #1 from Raymond Russell  2012-03-22 
06:28:07 UTC ---
The preprocessed output is too large (2028k) to add as an attachment.  I don't
have anywhere obvious to post it - do you have any suggestions on how to submit
it?


[Bug c++/52662] ICE in replace_reg_with_saved_mem, at caller-save.c:1125

2012-03-22 Thread raymond at corvil dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52662

--- Comment #3 from Raymond Russell  2012-03-22 
07:48:56 UTC ---
Created attachment 26951
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26951
Preprocessed code from successful compilation


[Bug c++/52662] ICE in replace_reg_with_saved_mem, at caller-save.c:1125

2012-03-22 Thread raymond at corvil dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52662

--- Comment #4 from Raymond Russell  2012-03-22 
07:49:59 UTC ---
Created attachment 26952
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26952
Preprocessed code that triggered ICE


[Bug c++/52662] ICE in replace_reg_with_saved_mem, at caller-save.c:1125

2012-03-22 Thread raymond at corvil dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52662

--- Comment #5 from Raymond Russell  2012-03-22 
07:54:11 UTC ---
Thanks, for some reason I thought compressed output wouldn't be kosher 
(i.e. I wasn't really thinking).  I've attached both sets of 
preprocessed code for completeness.

Many thanks,

Raymond.


On 03/22/12 07:24, rguenth at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52662
>
> --- Comment #2 from Richard Guenther  2012-03-22 
> 07:24:23 UTC ---
> You can compress it.
>


[Bug c++/36960] New: Reference variable in virtually inherited base corrupted under optimization

2008-07-28 Thread raymond at corvil dot com
Apologies if this is a duplicate:  I searched existing reports and found tons
of hits on "virtual inheritance" and "reference", but couldn't find anything
like this.  The following program illustrates the problem:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

struct Lower {
const int&  ref;

Lower(const int& ref) : ref(ref) { }
};


struct Middle : public virtual Lower {

Middle(const int& ref) : Lower(ref) { }
};


struct Upper : public Middle {

Upper(const int& ref) : Lower(ref), Middle(ref) { }

int get()
{
return ref;
}
};


int main()
{
int i = 0;
Upper upper(i);

return upper.get();
}


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Compiling this using 4.2.2 or 4.2.3 with -O2 or higher causes the resulting
binary to return a non-zero value;  3.4.2 produces a bug-free binary.  I've
seen the same effect in more complex code, where gdb gives an obviously wrong
address for the "ref" member.  Dropping to -O fixes the problem, as do several
other changes:

* Making "ref" an int (as opposed to an int&)
* Making Middle inherit non-virtually from Lower
* Accessing "ref" from Middle instead of Upper

The constness of the reference has no effect.


Issued command-line:
g++ -Wall -W -Wundef -Wpointer-arith -g -O2 VirtuallyInheritedReference.cpp

Full output from running with "-v --save-temps" is as follows:
g++ -v -save-temps -Wall -W -Wundef -Wpointer-arith -g -O2 -c -o /dev/null
VirtuallyInheritedReference.cpp

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /mnt/taw/usr/Taw/tmp/gcc-4.2.2/configure --prefix=/usr
--disable-nls --libexecdir=/usr/lib --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
--disable-bootstrap
Thread model: posix
gcc version 4.2.2
 /usr/lib/gcc/i686-pc-linux-gnu/4.2.2/cc1plus -E -quiet -v -D_GNU_SOURCE
VirtuallyInheritedReference.cpp -mtune=generic -Wall -W -Wundef -Wpointer-arith
-fworking-directory -O2 -fpch-preprocess -o VirtuallyInheritedReference.ii
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2

/usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2/i686-pc-linux-gnu
 /usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2/backward
 /usr/local/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.2.2/include
 /usr/include
End of search list.
 /usr/lib/gcc/i686-pc-linux-gnu/4.2.2/cc1plus -fpreprocessed
VirtuallyInheritedReference.ii -quiet -dumpbase VirtuallyInheritedReference.cpp
-mtune=generic -auxbase-strip /dev/null -g -O2 -Wall -W -Wundef -Wpointer-arith
-version -o VirtuallyInheritedReference.s
GNU C++ version 4.2.2 (i686-pc-linux-gnu)
compiled by GNU C version 4.2.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6ba594205d388e98f3b46dee442d61ac
 as -V -Qy -o /dev/null VirtuallyInheritedReference.s
GNU assembler version 2.18 (i686-pc-linux-gnu) using BFD version (GNU Binutils)
2.18
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



Contents of VirtuallyInheritedReference.ii:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# 1 "VirtuallyInheritedReference.cpp"
# 1 "/home/raymond/src/C++/gcc-bugs//"
# 1 ""
# 1 ""
# 1 "VirtuallyInheritedReference.cpp"

struct Lower {
 int& ref;

 virtual ~Lower() { }

 Lower(int& ref) : ref(ref) { }
};


struct Middle : public virtual Lower {

 Middle(int& ref) : Lower(ref) { }
};


struct Upper : public Middle {

 Upper(int& ref) : Lower(ref), Middle(ref) { }

 int get()
 {
  return ref;
 }
};


int main()
{
 int i = 0;
 Upper upper(i);

 return upper.get();
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


-- 
   Summary: Reference variable in virtually inherited base corrupted
under optimization
   Product: gcc
   Version: 4.2.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: raymond at corvil dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36960