This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/17346] New: linux kernel: handwritten offsetof break inline asm
- From: "matz at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Sep 2004 11:35:01 -0000
- Subject: [Bug inline-asm/17346] New: linux kernel: handwritten offsetof break inline asm
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The linux kernel has a file asm-context.c, which is used to get hold
of several offsets inside assembler. For this inline asm is used to
place the offsets directly into the assembler output, which later is parsed.
A testcase is this:
-------------------------------------
struct A { int a, b; };
void foo(void)
{ __asm volatile ("%0" : : "i" ((long)&((struct A*)0)->b)); }
-------------------------------------
The problem is, that the expression (T*)0->b is not thought to be constant
anymore, and is placed inside a register. The "i" constraints require a
constant of course, so we get this error message when compiling the above:
foo.c:3: warning: asm operand 0 probably doesn't match constraints
foo.c:3: error: impossible constraint in `asm'
Using __builtin_offsetof would fix this particular instance, but I think
that the expression really should be taken as constant by the optimizers.
--
Summary: linux kernel: handwritten offsetof break inline asm
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matz at suse dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17346