public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: spencer@infointeractive.com To: gcc-gnats@gcc.gnu.org Subject: c++/1877: gcc-20010122 and gcc-20010205 cause linker errors with static const int Date: Sun, 01 Apr 2001 00:00:00 -0000 [thread overview] Message-ID: <20010205191531.23479.qmail@sourceware.cygnus.com> (raw) >Number: 1877 >Category: c++ >Synopsis: gcc-20010122 and gcc-20010205 cause linker errors with static const int >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Mon Feb 05 11:16:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Brad Spencer >Release: 20010122 and 20010205 >Organization: >Environment: $ uname -a; /opt/gcc-20010122/bin/g++ -v SunOS starbug 5.6 Generic_105182-05 i86pc i386 i86pc Reading specs from /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/specs Configured with: ../gcc-20010122/configure --prefix=/opt/gcc-20010122 --enable-languages=c++ gcc version 2.97 20010122 (experimental) >Description: Code that uses the ternary operator (?:) with a "static const int" class data member in a certain way causes a strange linker error. Using "if-then" logic instead of "?:" or using an unsigned integer avoids the error. Complete source (no includes) of an example follows. // BEGIN class A { public: A() : var(2), flag(false) {} static const int c = 1; int var; bool flag; public: int f() const { return flag ? var : c; } }; int main() { A object; const int e = object.f(); return e; } // END Changing the definiton of the function "f" to int f() const { if(flag) return var; return c; } _or_ the definition of the constant "c" to static const unsigned int c = 1; does not generate the error. I used the codesourcery online compiler to try gcc-20010205 and my own installation for gcc-20010122. $ /opt/gcc-20010122/bin/g++ -v foo.cc Reading specs from /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/specs Configured with: ../gcc-20010122/configure --prefix=/opt/gcc-20010122 --enable-languages=c++ gcc version 2.97 20010122 (experimental) /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/cc1plus -v -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0 -Dunix -D__svr4__ -D__SVR4 -Dsun -D__unix__ -D__svr4__ -D__SVR4 -D__sun__ -D__unix -D__sun -Asystem=svr4 -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ foo.cc -D__GNUG__=2 -D_GNU_SOURCE -D__GXX_ABI_VERSION=100 -quiet -dumpbase foo.cc -version -o /var/tmp/ccu1T5ZL.s GNU CPP version 2.97 20010122 (experimental) (cpplib) (i386 System V Release 4) GNU CPP version 2.97 20010122 (experimental) (cpplib) (i386 System V Release 4) GNU C++ version 2.97 20010122 (experimental) (i386-pc-solaris2.6) compiled by GNU C version 2.95.2 19991024 (release). #include "..." search starts here: #include <...> search starts here: /opt/gcc-20010122/include/g++-v3 /opt/gcc-20010122/i386-pc-solaris2.6/include/g++-v3 /opt/gcc-20010122/include /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/include /opt/gcc-20010122/i386-pc-solaris2.6/include /usr/include End of search list. /usr/ccs/bin/as -V -Qy -s -o /var/tmp/ccG26AGw.o /var/tmp/ccu1T5ZL.s GNU assembler version 2.10 (i386-pc-solaris2.6) using BFD version 2.10 /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/collect2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/crt1.o /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/crti.o /usr/ccs/lib/values-Xa.o /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/crtbegin.o -L/opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97 -L/usr/ccs/bin -L/usr/ccs/lib -L/opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/../../.. /var/tmp/ccG26AGw.o -lstdc++ -lm -lgcc -lc -lgcc /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/crtend.o /opt/gcc-20010122/lib/gcc-lib/i386-pc-solaris2.6/2.97/crtn.o /var/tmp/ccG26AGw.o: In function `A::f() const': /var/tmp/ccG26AGw.o(.gnu.linkonce.t._ZNK1A1fEv+0x1d): undefined reference to `A::c ' GNU ld version 2.10 (with BFD 2.10) Supported emulations: elf_i386 collect2: ld returned 1 exit status --------- Reading specs from /usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/specs Configured with: ../configure --prefix=/tmp/gcc-20010205-root/usr/local --enable-shared --enable-threads --disable-checking i386-pc-linux-gnu : (reconfigured) gcc version 2.97 20010205 (experimental) /usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/cc1plus -v -iprefix /usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/ -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ /tmp/@933.7.cc -D__GNUG__=2 -D_GNU_SOURCE -D__GXX_ABI_VERSION=100 -quiet -dumpbase @933.7.cc -version -o /tmp/ccpehC9e.s GNU CPP version 2.97 20010205 (experimental) (cpplib) (i386 Linux/ELF) GNU CPP version 2.97 20010205 (experimental) (cpplib) (i386 Linux/ELF) GNU C++ version 2.97 20010205 (experimental) (i386-pc-linux-gnu) compiled by GNU C version 2.97 20010205 (experimental). ignoring nonexistent directory "/usr/local/include/g++-" ignoring nonexistent directory "/usr/local/i386-pc-linux-gnu/include/g++-" ignoring nonexistent directory "/tmp/gcc-20010205-root/usr/local/include/g++-" ignoring nonexistent directory "/tmp/gcc-20010205-root/usr/local/i386-pc-linux-gnu/include/g++-" ignoring nonexistent directory "/tmp/gcc-20010205-root/usr/local/lib/gcc-lib/i386-pc-linux-gnu/2.97/include" ignoring nonexistent directory "/tmp/gcc-20010205-root/usr/local/i386-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc-lib/i386-pc-linux-gnu/2.97/include /usr/local/i386-pc-linux-gnu/include /usr/local/include /usr/include End of search list. /tmp/@933.7.cc:21:1: warning: no newline at end of file as -V -Qy -o /tmp/cczmn0Hk.o /tmp/ccpehC9e.s GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version 2.9.1.0.24 /usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /tmp/@933.8 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/crtbegin.o -L/usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97 -L/usr/local/bin/../lib/gcc-lib -L/usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/../../.. /tmp/cczmn0Hk.o -lstdc++ -lm -lgcc -lc -lgcc /usr/local/bin/../lib/gcc-lib/i386-pc-linux-gnu/2.97/crtend.o /usr/lib/crtn.o /tmp/cczmn0Hk.o: In function `A::f() const': /tmp/cczmn0Hk.o(.gnu.linkonce.t._ZNK1A1fEv+0x1d): undefined reference to `A::c ' collect2: ld returned 1 exit status -------- It works with gcc-2.95.2. $ g++ -v foo.cc Reading specs from /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/specs gcc version 2.95.2 19991024 (release) /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dunix -D__svr4__ -D__SVR4 -Dsun -D__unix__ -D__svr4__ -D__SVR4 -D__sun__ -D__unix -D__sun -Asystem(svr4) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ foo.cc /var/tmp/ccigX8Yq.ii GNU CPP version 2.95.2 19991024 (release) (i386 System V Release 4) #include "..." search starts here: #include <...> search starts here: /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/../../../../include/g++-3 /usr/local/include /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/../../../../i386-pc-solaris2.6/include /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/include /usr/include End of search list. The following default directories have been omitted from the search path: End of omitted list. /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/cc1plus /var/tmp/ccigX8Yq.ii -quiet -dumpbase foo.cc -version -o /var/tmp/ccgRopdJ.s GNU C++ version 2.95.2 19991024 (release) (i386-pc-solaris2.6) compiled by GNU C version 2.95.2 19991024 (release). /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/as -V -Qy -o /var/tmp/ccCcMyD2.o /var/tmp/ccgRopdJ.s GNU assembler version 2.9.1 (i386-pc-solaris2.6), using BFD version 2.9.1 /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/collect2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/crt1.o /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/crti.o /usr/ccs/lib/values-Xa.o /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/crtbegin.o -L/opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2 -L/usr/ccs/bin -L/usr/ccs/lib -L/opt/gcc-2.95.2/lib /var/tmp/ccCcMyD2.o -lstdc++ -lm -lgcc -lc -lgcc /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/crtend.o /opt/gcc-2.95.2/lib/gcc-lib/i386-pc-solaris2.6/2.95.2/crtn.o GNU ld version 2.10 (with BFD 2.10) Supported emulations: elf_i386 >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: >From B.Touron@citb.bull.net Sun Apr 01 00:00:00 2001 From: B.Touron@citb.bull.net To: gcc-gnats@gcc.gnu.org Subject: c++/2208: Problem with g++ and templates Date: Sun, 01 Apr 2001 00:00:00 -0000 Message-id: <20010307183810.21369.qmail@sourceware.cygnus.com> X-SW-Source: 2001-q1/msg02086.html Content-length: 997 >Number: 2208 >Category: c++ >Synopsis: Problem with g++ and templates >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Mar 07 10:46:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Benoit Touron >Release: gcc version 2.95.2 19991024 (release) >Organization: >Environment: UnixWare bdsdev 5 7.1.0 i386 x86at SCO UNIX_SVR5 (result of uname -a) >Description: This program does not compile --> START template<class BASE_CLASS> class myclass : public BASE_CLASS { public: void fun(BASE_CLASS::mytype p) // GOT " parse error // before `)'" { return; } }; void main() { } <-- END BASE_CLASS is supposed to have type "mytype" defined inside it (and public). This file compiles OK with MS compiler. >How-To-Repeat: g++ -c test.cc >Fix: >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2001-04-01 0:00 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=20010205191531.23479.qmail@sourceware.cygnus.com \ --to=spencer@infointeractive.com \ --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).