Open jshufro opened 4 years ago
Also pasted the wrong program for the shown output. It has been a long day.
#include <stdio.h>
foo(int n) {
int cond;
printf("'Twas brillig and the slithy toves did gyre and gimble in the wabe.\n");
asm goto("" ::"r"(cond) : : label0);
label0:;
int a[n];
printf("All mimsy were the borogoves, ");
asm goto("" ::"r"(cond) : : label1);
label1:;
printf("and the mome raths outgrabe.\n");
}
main() {foo(1);}
Sorry- pasted a bit more of my terminal output than I intended.
foo(int n) {
int cond;
asm goto("" ::"r"(cond) : : label0);
label0:;
int a[n];
printf("'Twas brillig and the slithy toves did gyre and gimble in the wabe. All mimsy were the borogoves, and the mome raths outgrabe.");
asm goto("" ::"r"(cond) : : label1);
label1:;
}
main() {}
jacob@Joshua:~/tmp$ clang-10 main.c
main.c:3:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
foo(int n) {
^
main.c:8:3: error: cannot jump from this asm goto statement to one of its possible targets
asm goto("" ::"r"(cond) : : label0);
^
main.c:15:3: note: possible target of asm goto statement
label1:;
^
main.c:11:7: note: jump bypasses initialization of variable length array
int a[n];
^
main.c:21:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {foo(1);}
^
2 warnings and 1 error generated.
(failed reverse-i-search)`hg': ssh dh_apn5p3@s^Cf.ro
jacob@Joshua:~/tmp$ clang-10 main.c
main.c:3:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
foo(int n) {
^
main.c:8:3: error: cannot jump from this asm goto statement to one of its possible targets
asm goto("" ::"r"(cond) : : label0);
^
main.c:15:3: note: possible target of asm goto statement
label1:;
^
main.c:11:7: note: jump bypasses initialization of variable length array
int a[n];
^
main.c:21:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {foo(1);}
^
2 warnings and 1 error generated.
jacob@Joshua:~/tmp$ gcc main.c
main.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
3 | foo(int n) {
| ^~~
main.c:21:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
21 | main() {foo(1);}
| ^~~~
jacob@Joshua:~/tmp$ ./a.out
'Twas brillig and the slithy toves did gyre and gimble in the wabe.
All mimsy were the borogoves, and the mome raths outgrabe.
jacob@Joshua:~/tmp$
Could you give an example of adding code around the label that still triggers the bug?
I think that's not accurate, because adding code in and around the labels, or changing the conditionals to evaluate to false still presents this bug.
It's giving this warning because the "callbr" instruction can't have the default target listed in the indirect target list. My initial guess is that the front-end thinks that "label1" and "label0" are to the same place. Probably because the conditionals for the "if" statements are always true.
More discussion of this issue: https://reviews.llvm.org/D129288#3635747 cc @nikic @jyknight
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:
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.