I get an "undefined reference" error when linking two files but that variable
is static. This only happens with gcc 4.2, and only when I enable both -g and
-O1 (or higher).
(sid)473:[EMAIL PROTECTED]: ~] cat test.c
static const char utf8_skip_data[1] = {1};
static const char * const gconf_g_utf8_skip = utf8_skip_data;
(sid)474:[EMAIL PROTECTED]: ~] cat main.c
int main() {
}
(sid)475:[EMAIL PROTECTED]: ~] gcc -c -o main.o main.c
(sid)476:[EMAIL PROTECTED]: ~] gcc -c -g -O2 -o test.o test.c
(sid)477:[EMAIL PROTECTED]: ~] gcc main.o test.o
test.o:(.debug_info+0x93): undefined reference to `utf8_skip_data'
collect2: ld returned 1 exit status
zsh: exit 1 gcc main.o test.o
(sid)478:[EMAIL PROTECTED]: ~] gcc-4.1 -c -g -O2 -o test.o test.c
(sid)479:[EMAIL PROTECTED]: ~] gcc main.o test.o
(sid)480:[EMAIL PROTECTED]: ~] gcc -c -g -O0 -o test.o test.c
(sid)481:[EMAIL PROTECTED]: ~] gcc main.o test.o
(sid)482:[EMAIL PROTECTED]: ~]
This is with 4.2.0 20060419. 20060517 shows the same.
--
Summary: [4.2 regression] bogus undefined reference error to
static var with -g and -O
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tbm at cyrius dot com
GCC build triplet: powerpc-linux-gnu
GCC host triplet: powerpc-linux-gnu
GCC target triplet: powerpc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27657