public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17047] New: GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
@ 2004-08-16  9:34 do8896 at db dot com
  2004-08-16  9:43 ` [Bug c/17047] " do8896 at db dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: do8896 at db dot com @ 2004-08-16  9:34 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-08-16 13:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-16  9:34 [Bug c/17047] New: GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options do8896 at db dot com
2004-08-16  9:43 ` [Bug c/17047] " do8896 at db dot com
2004-08-16  9:44 ` do8896 at db dot com
2004-08-16 11:48 ` do8896 at db dot com
2004-08-16 13:35 ` schwab at suse dot de
2004-08-16 13:39 ` schwab at suse dot de
2004-08-16 13:40 ` schwab at suse dot de

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).