LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 3788 - asm inline : support casting on input operand
Summary: asm inline : support casting on input operand
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 3794 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-11 14:57 PDT by Matthieu castet
Modified: 2010-03-12 00:57 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthieu castet 2009-03-11 14:57:43 PDT
Hi :

$ cat /tmp/p.c 
int foo()
{
        int a;
        asm("nop"
                        :
                        : "m"((int)(a))
                        );
}

$ ./llvm/tools/clang/tools/ccc/ccc /tmp/p.c -c -o /tmp/p.o
/tmp/p.c:6:10: error: invalid lvalue in asm input for constraint 'm'
                        : "m"((int)(a))
                              ^~~~~~~~
1 diagnostic generated.


The casting should be the same thing than doing :

int foo()
{
        int a;
         int tmp = a;
        asm("nop"
                        :
                        : "m"(tmp)
                        );
}
Comment 1 Chris Lattner 2009-03-11 15:31:46 PDT
I'm sorry, but this is a bug that we don't want to be compatible with.  "m" operands require that you be able to take the address of the operand.  (int)x is an rvalue, and x is an lvalue.  We need an lvalue.
Comment 2 Chris Lattner 2009-03-12 12:37:09 PDT
*** Bug 3794 has been marked as a duplicate of this bug. ***
Comment 3 Chris Lattner 2009-03-13 10:41:12 PDT
I'm considering adding support for making the inline asm code ignore casts to the exact same type, but would make this an error by default requiring some funny option to enable it.  Would that fix this problem?
Comment 4 Diane Bruce 2009-03-13 10:59:51 PDT
(In reply to comment #3)
> I'm considering adding support for making the inline asm code ignore casts to
> the exact same type, but would make this an error by default requiring some
> funny option to enable it.  Would that fix this problem?
> 

Yes. 
Comment 5 Ed Schouten 2009-03-13 11:02:56 PDT
What about only allowing this when using -std=gnu*?
Comment 6 Chris Lattner 2009-03-13 11:05:02 PDT
we default to gnu mode.  I'll add something like -fheinous-gnu-extensions
Comment 7 Chris Lattner 2009-03-13 12:38:57 PDT
Implemented here:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090309/013929.html