<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - unsupported inline asm: input with type 'int' matching output with type 'unsigned long long'"
   href="https://llvm.org/bugs/show_bug.cgi?id=24501">24501</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>unsupported inline asm: input with type 'int' matching output with type 'unsigned long long'
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jtony@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14747" name="attach_14747" title="The test case file used to reproduce the error">attachment 14747</a> <a href="attachment.cgi?id=14747&action=edit" title="The test case file used to reproduce the error">[details]</a></span>
The test case file used to reproduce the error

This defect was first found when we try to build the open source
FFmpeg:valgrind.h.  while it builds fine with GCC, clang gives errors as
follows.

------------------------------------------------------------------------------
To reproduce:

<span class="quote">> cat q.C</span >
#include <valgrind/valgrind.h>

<span class="quote">> clang q.C</span >

In file included from q.C:1:
/usr/include/valgrind/valgrind.h:4516:47: error: unsupported inline asm: input
with type 'int' matching output with
      type 'volatile unsigned long long'
   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/valgrind/valgrind.h:646:49: note: expanded from macro
'VALGRIND_DO_CLIENT_REQUEST_EXPR'
                    : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
                                                ^
/usr/include/valgrind/valgrind.h:4554:47: error: unsupported inline asm: input
with type 'int' matching output with
      type 'volatile unsigned long long'
   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/valgrind/valgrind.h:646:49: note: expanded from macro
'VALGRIND_DO_CLIENT_REQUEST_EXPR'
                    : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
                                                ^
2 errors generated.
Error while processing q.C.
------------------------------------------------------------------------------




Because the valgrind.h is so large. I spent some time reducing it to a very
small test case (expand the macro _zzq_default, remove unrelated other parts),
which can still reproduce the above error. As follows:


------------------------------------------------------------------------------
<span class="quote">> cat q.C</span >
void VALGRIND_PRINTF(const char *format, ...)
{
   unsigned long _qzz_res = ({
         unsigned long long  int _zzq_result;
         __asm__ volatile("lgr 3,%1"
                        : "=d" (_zzq_result)
                        : "0" (/*(unsigned long long)i*/0)
                        );
         _zzq_result; });
}

<span class="quote">> clang q.C</span >

q.C:7:57: error: unsupported inline asm: input with type 'int' matching output
with type 'unsigned long long'
                        : "0" (/*(unsigned long long)i*/0)
                                                        ^
1 error generated.

------------------------------------------------------------------------------

If I explicitly cast 0 to unsigned long long, there will be no error. While I
agree it is dangerous to cast "unsigned long long" to "int" (<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - unsupported inline asm: input with type 'long' matching output with type 'int'"
   href="show_bug.cgi?id=14408">bug #14408</a>), but I
think it will be nice to make clang implicitly cast "int" to "unsigned long
long" in this case. Furthermore, it seems that only some type promotion work
need to be done in function Sema::ActOnGCCAsmStmt().

------------------------------------------------------------------------------
This bug exists in clang 3.4,3.5 and 3.6.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>