G++ reports a segmentation fault when compiling the code below.

Environment:
System: Linux temporal.corp.google.com 2.6.18.5-gg34workstation-mixed64-32 #1
SMP Thu May 8 01:31:23 UTC 2008 x86_64 GNU/Linux
Architecture: x86_64

host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk-default --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
--disable-werror --with-tune=pentium4 --enable-checking=release i486-linux-gnu

How-To-Repeat:
Invoke g++ on the following (invalid) code with no other arguments.
There are no #includes; this is the entire source file.

======================
namespace a {
  template <typename T> class Foo;
}

namespace b {
  template <> class ::a::Foo<double> {};
}
======================

(The gccbug script claims it will remove "comments" delimited by angle
brackets.
Hopefully that isn't actually true because it will mess up the above code
sample as well as the following error log.)

Result:
testtemplate.cc:6: error: global qualification of class name is invalid before
'{' token
testtemplate.cc:6: error: specialization of 'template<class T> struct a::Foo'
in different namespace
testtemplate.cc:2: error:   from definition of 'template<class T> struct
a::Foo'
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions, see
<URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.


------- Comment #1 from kenton at google dot com  2008-08-11 22:23 -------
Fix:
Unknown.


-- 
           Summary: Segfault on compiling template defined in wrong
                    namespace.
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kenton at google dot com
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37087

Reply via email to