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

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sat Feb 5 15:22:00 GMT 2000


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

Thanks for your bug report. The mainline compiler (2.96 20000125
(experimental)) says

crackpipe.cpp: In function `int main ()':
crackpipe.cpp:41: initializing non-const `crackrock &' with `int' will use a temporary
crackpipe.cpp:43: request for member `smokeTheRock' in `myPipe', which is of non-aggregate type `crackpipe () ()'
crackpipe.cpp: In method `void crackpipe::putInPipe (_T) [with _T = crackrock]':
crackpipe.cpp:29:   instantiated from here
crackpipe.cpp:35: no match for `crackrock & != int'

so the bug has been fixed; g++ now correctly diagnoses the errors in
your code. The critical error is the declaration of

    crackpipe myPipe();

which does not declare a local variable, initialized with the default
ctor; instead, it declares a function returning crackpipe. As a result,
myPipe.smokeTheRock(myRock) is not a meaningful construct.

Correcting the other problems in your code, the mainline compiler
accepts it just fine. 2.95 will accept it after smokeTheRock is
out-of-line; I'll attach the corrected version below.

Regards,
Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: crackpipe.cpp
Type: text/x-c++
Size: 1192 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000205/09d7747e/attachment.bin>


More information about the Gcc-bugs mailing list