Internal compiler error
Raymond Nijssen
raymond@mailhost.magma-da.com
Fri Dec 19 13:21:00 GMT 1997
Dear egcs maintainers,
Thanks for all your effort to ensure that there will be a free
compiler on the leaving C++ train!
Regardless of whether or not this code fragment is an example of dirty
tricks (does anybody know a better way to do what this function
does?) .... it triggers an internal compiler error.
This compiles fine with g++-2.7.2.3 and other compilers.
Regards,
-Raymond
> cat bug1.cxx
// This function will translate a pointer to a member of a struct to a pointer to the struct.
// This is needed to embed a list implementation as a member of the struct.
// It is a type-safe implementation of
// (STRUCT *) ((int) memberp - offset(STRUCT, member);
template <class STRUCT, class MEMBER> inline STRUCT *
setback(MEMBER *bp, MEMBER STRUCT::*offset)
{
// The implementation of this function may be platform dependend
if(!bp) return 0; // NULL pointers remain NULL
union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't work.
u.of = offset;
return (STRUCT *) ((int) bp - u.i);
}
> g++ -v bug1.cxx
Reading specs from /usr/local/egcs-1.0/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)
/usr/local/egcs-1.0/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) bug1.cxx /var/tmp/cca0014T.ii
GNU CPP version egcs-2.90.21 971202 (egcs-1.00 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/egcs-1.0
/usr/local/include
/usr/local/egcs-1.0/sparc-sun-solaris2.5.1/include
/usr/local/egcs-1.0/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/include
/usr/include
End of search list.
/usr/local/egcs-1.0/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/cc1plus /var/tmp/cca0014T.ii -quiet -dumpbase bug1.cc -version -o /var/tmp/cca0014T.s
GNU C++ version egcs-2.90.21 971202 (egcs-1.00 release) (sparc-sun-solaris2.5.1) compiled by GNU C version 2.7.2.3.
bug1.cxx: In function `STRUCT * setback(MEMBER *, MEMBER STRUCT::*)':
bug1.cxx:11: Internal compiler error.
bug1.cxx:11: Please submit a full bug report to `egcs-bugs@cygnus.com'.
More information about the Gcc-bugs
mailing list