Public bug reported: Binary package hint: gcc-4.4
With this file as the only input: ============== class A { A * get_a_pointer(); }; template <class T> void function() { A::get_a_pointer().anything; } ============== The g++ crashes with this output: ============== ‘ crashy_test.cpp:9: confused by earlier errors, bailing out Preprocessed source stored into /tmp/ccWR7fhP.out file, please attach this to your bugreport. ============== A box pops up with the message "Sorry, the program cc1plus closed unexpectedly". Here is the preprocessed source it saved: ============== // /usr/lib/gcc/x86_64-linux-gnu/4.4.1/cc1plus -quiet -D_GNU_SOURCE crashy_test.cpp -D_FORTIFY_SOURCE=2 -quiet -dumpbase crashy_test.cpp -mtune=generic -auxbase crashy_test -fstack-protector -o - -frandom-seed=0 # 1 "crashy_test.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "crashy_test.cpp" class A { A * get_a_pointer(); }; template <class T> void function() { A::get_a_pointer().anything; } ============== Other info: It doesn't seem to matter that 'anything' doesn't exist. Replacing it with a member (variable or function) that does exist doesn't make a difference. You get a similar error even if you remove the last '}'. This bug should be low priority, since it only occurs if your code has two errors g++ should be reporting (in the second to last line): -You cannot call A::get_a_pointer() without an object, and -You cannot request members from the non-class type A*. I don't mind it reporting one of these errors, then bailing out without crashing. The problem goes away if you make A::get_a_pointer static, or if you replace the . with ->. It also goes away if you make function not a template function. It can be reproduced if you make function a member function of a templated class instead. $ g++ -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) $ apt-cache policy gcc-4.4 gcc-4.4: Installed: 4.4.1-4ubuntu8 Candidate: 4.4.1-4ubuntu8 Version table: *** 4.4.1-4ubuntu8 0 500 http://gb.archive.ubuntu.com karmic/main Packages 100 /var/lib/dpkg/status $ uname -a Linux ubuntu 2.6.31-16-generic #53-Ubuntu SMP Tue Dec 8 04:02:15 UTC 2009 x86_64 GNU/Linux $ lsb_release -rd Description: Ubuntu 9.10 Release: 9.10 ** Affects: gcc-4.4 (Ubuntu) Importance: Undecided Status: New -- templates with class and pointer error cause bailing out and crash https://bugs.launchpad.net/bugs/503668 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs