[llvm-bugs] [Bug 49167] New: Clang accept invalid inline asm

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 12 13:00:06 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49167

            Bug ID: 49167
           Summary: Clang accept invalid inline asm
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhan3299 at purdue.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Hi,

I got an invalid program:

---
int a;
int main() { asm("" : "=a"(a), "=d"(a) : "d"(.1), "1"(&a)); }
---

I use c-reduce to get the minimal test-case. It is an invalid code. But clang
version 11.1.0 accepts it by accident (my apt-installed 6.0.0 also accepts it).

Note that above code is rejected by GCC (I tested from 6.0 to 10.0) no matter
what optimization level is used. Specifically, GCC blames that ‘asm’ operand
has impossible constraints.

I guess clang should have checked it. Otherwise it may generate code with
unpredictable behaviors, when compiling the bogus code with other complex code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210212/9e0970ae/attachment.html>


More information about the llvm-bugs mailing list