[llvm-bugs] [Bug 45903] New: overrestrictive asm goto gotolabels limitations

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 13 07:53:34 PDT 2020


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

            Bug ID: 45903
           Summary: overrestrictive asm goto gotolabels limitations
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jacob at shuf.ro
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

First of all, I apologize if this is the wrong venue for this bug report.
The following does not compile, even though I believe it should:
---------------------------------------------------
cleanup_cb(*p1) {}

foo(int n) {
  int cond;

  if (({
        asm goto("" ::"r"(cond) : : label0);
        1;
      }))
  label0:;

  int a[n];

  if (({
        asm goto("" ::"r"(cond) : : label1);
        1;
      }))
  label1:;

}

main() {}
---------------------------------------------------
jshufro at 660:~/asmgoto$ clang-10 main.c
main.c:1:13: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]
cleanup_cb(*p1) {}
            ^
main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
cleanup_cb(*p1) {}
^
main.c:1:18: warning: non-void function does not return a value [-Wreturn-type]
cleanup_cb(*p1) {}
                 ^
main.c:3:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
foo(int n) {
^
main.c:7:9: error: cannot jump from this asm goto statement to one of its
possible targets
        asm goto("" ::"r"(cond) : : label0);
        ^
main.c:18:3: note: possible target of asm goto statement
  label1:;
  ^
main.c:12:7: note: jump bypasses initialization of variable length array
  int a[n];
      ^
main.c:22:1: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]
main() {}
^
5 warnings and 1 error generated.
---------------------------------------------------

This is C-Reduced to be fairly minimal. Replacing the variable length array
with an __attribute__((cleanup)) variable causes a similar issue. It's worth
noting that the error is noting a possible target of asm goto that isn't listed
in the GoToLabels.

-- 
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/20200513/34cf1bd4/attachment.html>


More information about the llvm-bugs mailing list