Bug 19969 - Labels broken when passed into inline assembly.
Summary: Labels broken when passed into inline assembly.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 34634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-02-15 03:11 UTC by Eric Stith
Modified: 2024-03-16 18:08 UTC (History)
2 users (show)

See Also:
Host: 3.4.3
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Stith 2005-02-15 03:11:00 UTC
The following code breaks when compiled with -O3 or -O2, because the label 
seems to be misplaced.  This problem seems to be restricted to situations where 
I pass the address of a label into an assembly routine to be used.  When 
compiled without optimizations or with -O1, it works properly.  I´m compiling 
in FreeBSD 5.3-RELEASE gcc version 3.4.3, and I have confirmed that it occurs 
also on Knoppix 3.6 with compiler version 3.3.4.  No flags other than 
aforementioned optimization flags were used in any case.  I hope this is enough 
info. 
 
main() 
{ 
        puts("This line should print.\n"); 
 
        asm("jmpl *%0\n":: "q" (&&foo)); 
        puts("This line should not print"); 
foo: 
        puts("And this line should print.\n"); 
}
Comment 1 Andrew Pinski 2005-02-15 03:14:15 UTC
This is not a bug, Labels can be moved if you don't use them as computed gotos in which this case you 
don't use it for that.  Also note asms cannot, I repeat cannot change the flow of a program at all.
Comment 2 Andreas Schwab 2008-01-01 09:22:20 UTC
*** Bug 34634 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2024-03-16 18:08:33 UTC
Note starting with GCC 4.5, gcc adds asm goto which can be used to do what is needed to be done here.