[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#198261: g++ segfaults when using namespaced typedef of primitive type as struct



Package: g++
Version: 3.3-1

First of all, I want to say thank you for a great magazine.  I happened
to stumble upon a little bug just now that I thought you might want to
hear about, since I did not find it reported anywhere.

The following code causes g++ to segfault:

    === test.cc ===
    namespace ns { typedef int integer; }
    struct ns::integer i;
    === end ===
    
    $ g++ test.cc
    test.cc:2: internal compiler error: Segmentation fault
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <URL:http://gcc.gnu.org/bugs.html> for instructions.

The expected behaviour occurs when not using a namespace:

    === test2.cc ===
    typedef int integer;
    struct integer i;
    === end ===
    
    $ g++ test2.cc
    test2.cc:2: error: using typedef-name `integer' after `struct'
    test2.cc:2: error: ISO C++ forbids declaration of `i' with no type

When the erroneous `struct' at test.cc:2 is replaced by `enum' or
`class', g++ still segfaults.  I don't know anything about the inner
workings of g++, so unfortunately I cannot hypothesize the cause of the
problem.  Anyway, I hope the fix is an easy one!

Some possibly relevant information follows:

    $ g++ -v
    Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs
    Configured with: ../src/configure -v
    --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang
    --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
    --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
    --with-system-zlib --enable-nls --without-included-gettext
    --enable-__cxa_atexit --enable-clocale=gnu --enable-debug
    --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
    i386-linux
    Thread model: posix
    gcc version 3.3 (Debian)
    
    $ uname -a
    Linux teepee 2.4.18-bf2.4 #1 Son Apr 14 09:53:28 CEST 2002 i686
    GNU/Linux

Good luck and best regards,

-- 
Daniel Brockman
<daniel@brockman.nu>




Reply to: