From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12934 invoked by alias); 12 Dec 2002 00:06:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 12910 invoked by uid 71); 12 Dec 2002 00:06:01 -0000 Resent-Date: 12 Dec 2002 00:06:01 -0000 Resent-Message-ID: <20021212000601.12909.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, wirawan0@softhome.net Received: (qmail 11564 invoked by uid 61); 12 Dec 2002 00:00:57 -0000 Message-Id: <20021212000057.11563.qmail@sources.redhat.com> Date: Wed, 11 Dec 2002 16:06:00 -0000 From: wirawan0@softhome.net Reply-To: wirawan0@softhome.net To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8906: G++ 3.2 raises segmentation fault when parsing nested-class definition X-SW-Source: 2002-12/txt/msg00677.txt.bz2 List-Id: >Number: 8906 >Category: c++ >Synopsis: G++ 3.2 raises segmentation fault when parsing nested-class definition >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Dec 11 16:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Wirawan Purwanto >Release: g++ version 3.2 >Organization: >Environment: Linux (Redhat 7.3) or Windows 2000 (cygwin) or SunSPARC machine (running Solaris) >Description: Brief: happens in G++ version 3.2 when parsing the definition of a nested class definition, if the "outer" class is a templatized class. This problem is also-reproducible in SunSPARC and Win32's version of GCC 3.2 >How-To-Repeat: Please take a look at the attachment for more details. It contains a small piece of code to trigger the error. In brief, try to compile the following: template class CLASS1 { class Nested1 { class Nested2; }; }; template class CLASS1<_stuff>::Nested1::Nested2 // <--error here!!! { public: int x; }; /* NOTE: it turns out that the same problem occurs if the outermost class is an ordinary class (not templatized) */ >Fix: Don't know. Note that DEC CXX complains if I use the second kind of declaration (cf. the attachment, the part compiled with -DNOT_BUGGY=2). >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="gcc-3.2-bugs.nested-class-decl.txt" Content-Disposition: inline; filename="gcc-3.2-bugs.nested-class-decl.txt" #if 0 ** BUG REPORT FOR GNU C++ VERSION 3.2 ************************************ Date: 11-Dec-2002 Subject: Bug in G++ version 3.2 in nested class definition Contact: Please write to me if you need more info; note that I am not subscribed to GCC mailing list. Brief: happends in G++ version 3.2 when parsing the definition of a nested class definition, if the "outer" class is a templatized class Compiler: GNU C++ version 3.2 OS: Red Hat Linux 7.3 Machine: a Sony VAIO PCG-FXA53 laptop CPU: AMD Athlon XP 1500+ "/usr/local/bin/g++ -v" says: Reading specs from /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs Configured with: /misc/src/gcc-3.2/configure --prefix=/usr/local/gcc-3.2 --disable-nls --enable-languages=c,c++,f77 Thread model: posix gcc version 3.2 Description: The problem can be reproduced using the code piece enclosed below. If you put switch -DNOT_BUGGY=1 or -DNOT_BUGGY=2, it will compile OK. But if you don not define NOT_BUGGY (or use -DNOT_BUGGY=0), it will give a segmentation fault. This problem is also-reproducible in SunSPARC and Win32! The same segmentation fault also occurs in GNU C++ version 3.2 that is run in SunSPARC. On the Sun machine, "uname -a" returns: SunOS 5.7 Generic_106541-18 sun4u sparc SUNW,Ultra-60 and "g++ -v" returns an essentially identical output to the previous one (i.e. --disable-nls --enable-language=c,c++,f77). I am also able to produce the same error in CYGWIN distribution of GNU C++ 3.2 (i.e. gcc version 3.2 20020818 (preprelease)). I also tried GNU C++ version 2.96 (on the same Red Hat machine), released by Red Hat, as a reference. The abovementioned error does NOT occur with this compiler. Invoking "g++ -v" for this compiler returns: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) APPENDICES: OUTPUT FROM COMMAND: /usr/local/bin/g++ -x c++ -v -DNOT_BUGGY=0 gcc-3.2-bugs.nested-class-decl.txt -S Reading specs from /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs Configured with: /misc/src/gcc-3.2/configure --prefix=/usr/local/gcc-3.2 --disable-nls --enable-languages=c,c++,f77 Thread model: posix gcc version 3.2 /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/cc1plus -v -iprefix /usr/local/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2/ -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -DNOT_BUGGY=0 gcc-3.2-bugs.txt -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase gcc-3.2-bugs.txt -version -o gcc-3.2-bugs.s GNU CPP version 3.2 (cpplib) (i386 Linux/ELF) GNU C++ version 3.2 (i686-pc-linux-gnu) compiled by GNU C version 3.2. ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../../include/c++/3.2" ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../../include/c++/3.2/i686-pc-linux-gnu"ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../../include/c++/3.2/backward" ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/include" ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../../i686-pc-linux-gnu/include" ignoring nonexistent directory "/usr/local/gcc-3.2/i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/gcc-3.2/include/c++/3.2 /usr/local/gcc-3.2/include/c++/3.2/i686-pc-linux-gnu /usr/local/gcc-3.2/include/c++/3.2/backward /usr/local/include /usr/local/gcc-3.2/include /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/include /usr/include End of search list. gcc-3.2-bugs.nested-class-decl.txt:134: internal error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See for instructions. #endif // end of the bug report. HERE IS THE CODE PIECE: #if NOT_BUGGY == 1 // -------------- this compiles OK ------------------ template class CLASS1 { class Nested1 { class Nested2 { public: int x; }; }; }; #elif NOT_BUGGY == 2 // -------------- this also compiles OK ------------- template class CLASS1 { class Nested1 { class Nested2 { public: int x; }; }; }; #else // this is the BUGGY kind of declaration: -------------------------- template class CLASS1 { class Nested1 { class Nested2; }; }; template class CLASS1<_stuff>::Nested1::Nested2 // !!! <-- the error happens here { public: int x; }; #endif // below is just a stub, disregard it. int main(int argc, char *argv[], char *env[]) { CLASS1::Nested1::Nested2 x; return 0; }