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

* [Bug c/17047] GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
  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 ` do8896 at db dot com
  2004-08-16  9:44 ` do8896 at db dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: do8896 at db dot com @ 2004-08-16  9:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From do8896 at db dot com  2004-08-16 09:43 -------
Created an attachment (id=6935)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6935&action=view)
file with example


-- 


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


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

* [Bug c/17047] GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: do8896 at db dot com @ 2004-08-16  9:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From do8896 at db dot com  2004-08-16 09:44 -------
Created an attachment (id=6936)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6936&action=view)
Compiler and linker logs for -Os options (for -O2 and -O3 result is the same)


-- 


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


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

* [Bug c/17047] GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: do8896 at db dot com @ 2004-08-16 11:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From do8896 at db dot com  2004-08-16 11:48 -------
Some details:

Failed at:
gcc -funit-at-a-time main.c -o main 

-O2, -O3 and -Os includes -funit-at-a-time


-- 


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


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

* [Bug c/17047] GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: schwab at suse dot de @ 2004-08-16 13:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-08-16 13:35 -------
There is no way for gcc to see the reference in the asm.  Either use 
__attribute__((used)) to tell it that the variable is used, or make the 
dependency explicit in the asm by adding it as a parameter. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c/17047] GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: schwab at suse dot de @ 2004-08-16 13:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-08-16 13:39 -------
Duplicate. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug c/17047] GCC incorrectly recognizes static vars when they are meet in asm blocks with -O2,-O3,-Os compiler options
  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
                   ` (4 preceding siblings ...)
  2004-08-16 13:39 ` schwab at suse dot de
@ 2004-08-16 13:40 ` schwab at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: schwab at suse dot de @ 2004-08-16 13:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-08-16 13:40 -------


*** This bug has been marked as a duplicate of 16551 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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