This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/27657] New: [4.2 regression] bogus undefined reference error to static var with -g and -O


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:tbm@reyes: ~] cat test.c
static const char utf8_skip_data[1] = {1};
static const char * const gconf_g_utf8_skip = utf8_skip_data;
(sid)474:tbm@reyes: ~] cat main.c
int main() {
}
(sid)475:tbm@reyes: ~] gcc -c -o main.o main.c
(sid)476:tbm@reyes: ~] gcc -c -g -O2 -o test.o test.c
(sid)477:tbm@reyes: ~] 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:tbm@reyes: ~] gcc-4.1 -c -g -O2 -o test.o test.c
(sid)479:tbm@reyes: ~] gcc main.o test.o
(sid)480:tbm@reyes: ~] gcc -c -g -O0 -o test.o test.c
(sid)481:tbm@reyes: ~] gcc main.o test.o
(sid)482:tbm@reyes: ~]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]