First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 29808
Product:  
Component:  
Status: RESOLVED
Resolution: INVALID
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: bero@arklinux.org
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 29808 depends on: Show dependency tree
Show dependency graph
Bug 29808 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2006-11-12 09:05
The following code (extracted from the Linux kernel) fails to compile with
optimization enabled:

static void load_fs(unsigned short sel)
{
        asm("mov %0, %%fs" : : "g"(sel));
}

int main(int argc, char **argv)
{
        load_fs(0);
}


[bero@dhcppc1 arklinux]$ gcc test.c
[bero@dhcppc1 arklinux]$ gcc -O1 test.c
/tmp/ccSpA5Rm.s: Assembler messages:
/tmp/ccSpA5Rm.s:13: Error: suffix or operands invalid for `mov'

gcc is 4.2 SVN revision 118519 (20061106).

------- Comment #1 From Segher Boessenkool 2006-11-12 11:10 -------
Not a bug in GCC but in your code; "g" says immediate values
are allowed, while this asm insn only takes registers (or 16-bit
memory).

------- Comment #2 From Richard Guenther 2006-11-12 13:26 -------
invalid

------- Comment #3 From bero@arklinux.org 2006-11-12 13:40 -------
If the code is invalid, the fact that it compiles with -O0 is probably a bug...

------- Comment #4 From Segher Boessenkool 2006-11-12 14:01 -------
> If the code is invalid, the fact that it compiles with -O0 is probably a bug...

No, GCC cannot in general detect whether your asm code is buggy.
The assembler however can detect many asm bugs, as it did in this
case.

The reason it worked with -O0 is that with -O0 you get different
generated code (namely, very inefficient code).

------- Comment #5 From Andrew Pinski 2006-11-12 17:15 -------
(In reply to comment #3)
> If the code is invalid, the fact that it compiles with -O0 is probably a bug...
No it is not really a bug that it compiles at -O0 either becuase "g" means
"r"+"i" so the register allocator in the -O0 case is selecting "r" while in the
optimize case is selecting "i".

First Last Prev Next    No search results available      Search page      Enter new bug