public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: wirawan0@softhome.net To: gcc-gnats@gcc.gnu.org Subject: c++/8906: G++ 3.2 raises segmentation fault when parsing nested-class definition Date: Wed, 11 Dec 2002 16:06:00 -0000 [thread overview] Message-ID: <20021212000057.11563.qmail@sources.redhat.com> (raw) >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: <Segmentation fault> 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 _stuff> class CLASS1 { class Nested1 { class Nested2; }; }; template <class _stuff> 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 <wirawan0@softhome.net> if you need more info; note that I am not subscribed to GCC mailing list. Brief: <Segmentation fault> 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 <a-host-name> 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 <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. #endif // end of the bug report. HERE IS THE CODE PIECE: #if NOT_BUGGY == 1 // -------------- this compiles OK ------------------ template <class _stuff> class CLASS1 { class Nested1 { class Nested2 { public: int x; }; }; }; #elif NOT_BUGGY == 2 // -------------- this also compiles OK ------------- template <class _stuff> class CLASS1 { class Nested1 { class Nested2 { public: int x; }; }; }; #else // this is the BUGGY kind of declaration: -------------------------- template <class _stuff> class CLASS1 { class Nested1 { class Nested2; }; }; template <class _stuff> 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<int>::Nested1::Nested2 x; return 0; }
reply other threads:[~2002-12-12 0:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20021212000057.11563.qmail@sources.redhat.com \ --to=wirawan0@softhome.net \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).