[LLVMbugs] [Bug 10536] New: Wrong implicit cast on inline asm operands

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 29 14:35:45 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10536

           Summary: Wrong implicit cast on inline asm operands
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: matthewbg at google.com
                CC: llvmbugs at cs.uiuc.edu, echristo at gmail.com


$ cat testcases/asm-uninit.cc
inline void atomic_thread_fence_acq_rel() {
  int dummy;
  __asm__ __volatile__("xchg %[value], %[mem]"  
                       : [value] "=r" (dummy)
                       : [mem] "m" (dummy)
                       : "memory");
}
$ clang -cc1 -fsyntax-only -ast-dump -Wuninitialized testcases/asm-uninit.cc
testcases/asm-uninit.cc:5:37: warning: variable 'dummy' is uninitialized when
used here
                       : [mem] "m" (dummy)
                                    ^~~~~
testcases/asm-uninit.cc:2:3: note: variable 'dummy' is declared here
  int dummy;
  ^
testcases/asm-uninit.cc:2:12: note: add initialization to silence this warning
  int dummy;
           ^
            = 0
<snip>
inline void atomic_thread_fence_acq_rel() (CompoundStmt 0x30f6a10
<testcases/asm-uninit.cc:1:43, line:7:1>
  (DeclStmt 0x30f6650 <line:2:3, col:12>
    0x30cc390 "int dummy")
  (AsmStmt 0x30f6990 <line:3:3, line:6:34>
    (DeclRefExpr 0x30f67d8 <line:4:40> 'int' lvalue Var 0x30cc390 'dummy'
'int')
    (ImplicitCastExpr 0x30f6978 <line:5:37> 'int' <LValueToRValue>
      (DeclRefExpr 0x30f68a8 <col:37> 'int' lvalue Var 0x30cc390 'dummy'
'int'))))

1 warning generated.

We're generating an LValueToRValue cast on the output operand and not on the
input operand, which seems odd (and leads to an uninitialized warning on the
wrong operand).

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list