This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GCC 2.95.2 bug report...private template function crash.



This is something I've come across porting some particularly ugly MSVC++
code to GCC 2.95.2... Basically the gist is that if I use a private
template function in a class, GCC gives an "internal compiler error".

I'm not really sure this is legal syntax under the c++ standard, but none
the less, an internal compiler error is never good.

Since the code I'm porting is proprietary (and I'm sure the company
wouldn't want their dirty laundry aired on the GCC buglist...), I've
boiled the code down to the simplest program I could that still generates
the compiler error. The problem appears to be coming from the template in
the "private:" section of the class.

Attached is the .cpp program, a .ZIP file of the .ii output, the (almost
empty) .s file, and stderr.txt, which contains the stderr output from GCC.

The command line used was:

 gcc -v --save-temps crackpipe.cpp 2> stderr.txt

This is on Linux kernel 2.2.14, RedHat 6.1 (glibc2.1, yadda yadda)

Please forgive the naming convention in the .cpp file; I've a sick sense
of humor.  :)

Any questions can be directed to icculus@lokigames.com ...I'll try to help
in whatever meager way I can.

---
Ryan C. Gordon
Programmer
Loki Entertainment Software


private_template_function_bug_cpp_output.zip

Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ crackpipe.cpp crackpipe.ii
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cc1plus crackpipe.ii -quiet -dumpbase crackpipe.cc -version -o crackpipe.s
GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release).
crackpipe.cpp: In method `void crackpipe::putInPipe<crackrock>(crackrock)':
crackpipe.cpp:29:   instantiated from here
crackpipe.cpp:35: Internal compiler error.
crackpipe.cpp:35: Please submit a full bug report.
crackpipe.cpp:35: See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for instructions.
	.file	"crackpipe.cpp"
	.version	"01.01"
gcc2_compiled.:

// In case you're wondering about the naming scheme, I'm trying to get
//  across the point that this example makes gcc act like it is on crack.
//
// Don't know if this code is valid in the first place, but an "internal
//  compiler error" message is never good behavior, so I'm sending this in.
//
// This was based on some commercial MSVC++ code Loki is porting. (I'll
//  keep my mouth shut about specifically what. :)  ), but was written
//  from scratch to trigger the same error as the proprietary code, so I
//  guess we can consider the below junk to be in the public domain.
//
// Fails on GCC 2.95.2 (and probably others, but haven't checked)...
//
//  --ryan.  (icculus@lokigames.com)

#include <cstdlib>

class crackrock
{
public:
    crackrock(int _purity) { purity = _purity; }
    int purity;
};

class crackpipe
{
public:
    void smokeTheRock( crackrock &rock ) { putInPipe(rock); }

private:
    bool smokable;

    template < class _T >
    void putInPipe( _T sample ) { smokable = (sample != NULL); }
};

int main(void)
{
    crackpipe myPipe();
    crackrock &myRock(2);

    myPipe.smokeTheRock(myRock);
    return(0);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]