This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/14105] New: GCC over-optimisating extern
- From: "ok at mailcall dot com dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Feb 2004 05:48:00 -0000
- Subject: [Bug c/14105] New: GCC over-optimisating extern
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Sample code (x.c):
int main(void) {
int return_pcap_debug(void) {
extern int pcap_debug;
return pcap_debug;
}
return 0;
}
Compiled with (-Os, -O1, -O2 are all the same):
gcc x.c -o x
Produces:
/tmp/ccJy8Ead.o(.text+0xa): In function `return_pcap_debug.0':
: undefined reference to `pcap_debug'
collect2: ld returned 1 exit status
But, when compiled with:
gcc -O3 x.c -o x
The code compiles.
This is an over-optimisation, and is pretty silly, especially since the returned
value in the inlined block is an extern.
If you link the code against something that does export pcap_debug, it links
properly.
--
Summary: GCC over-optimisating extern
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ok at mailcall dot com dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i586-trustix-linux
GCC host triplet: i586-trustix-linux
GCC target triplet: i586-trustix-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14105