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 c/17047] New: GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options


GCC incorrectly parses such blocks:

static unsigned long long myVar=0x0LL;

static void myFunc(){
  asm volatile ("movq myVar, %mm3");
};

int main(){
  myFunc();
  return 0;
}

-------------------------
In the result in object file, which compiled with command: "gcc -O3 -c main.c -o
main.o",(-O3 may be substituted on -O2 or -Os (with -O1,-O0 it works correctly))
if I do "nm main.o", the result is:

00000000 T main
         U myVar

i.e. gcc thinks that myVar will be defined as extern, but it is static :(
and gcc main.o -o main fail with result:

main.o(.text+0x6): In function `main':
: undefined reference to `myVar'
collect2: ld returned 1 exit status
It error also in 3.3.2 version of GCC.

-- 
           Summary: GCC incorrectly recognizes static vars when they are
                    meet in asm blocks with -O2,-O3,-Os compiler options
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: do8896 at db dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17047


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