Skip to content

overrestrictive asm goto gotolabels limitations #45248

@jshufro

Description

@jshufro
Bugzilla Link 45903
Version 10.0
OS Linux
CC @DougGregor,@isanbard,@jshufro,@nickdesaulniers,@zygoloid

Extended Description

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@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions