[Bug 503668] Re: [PR44627] templates with class and pointer error cause bailing out and crash

Bug Watch Updater 503668 at bugs.launchpad.net
Sat Mar 23 22:07:21 UTC 2013


** Changed in: gcc
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.4 in Ubuntu.
https://bugs.launchpad.net/bugs/503668

Title:
  [PR44627] templates with class and pointer error cause bailing out and
  crash

Status in The GNU Compiler Collection:
  Fix Released
Status in “gcc-4.4” package in Ubuntu:
  Fix Released

Bug description:
  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

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/503668/+subscriptions




More information about the foundations-bugs mailing list