| Issue |
235007
|
| Summary |
[clang] Conflicting fixed-register input constraints are silently accepted
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
mu-mu-mu
|
The following inline assembly specifies two inputs that require RAX but have different constant values.
### Reproducer (x86-64 Linux)
```
#include <stdio.h>
int main(void)
{
unsigned long value;
__asm__ volatile("movq %%rax, %0"
: "=&r"(value)
: "a"(0UL), "a"(1UL));
printf("rax=%lu\n", value);
}
```
### Actual behavior
clang silently accepts the code:
```
clang -O0 -Wall -Wextra repro.c
./repro
# rax=1
```
For comparison, GCC rejects it:
```
gcc repro.c
repro.c: In function 'main':
repro.c:6:5: error: 'asm' operand has impossible constraints or there are not enough registers
```
### Question
The above case has conflicts, as both inputs require the same register with different constant values.
Should clang diagnose (error, as GCC does, or at least a warning) this case?
Motivation: I encountered this while debugging an inline assembly statement, and a diagnostic would have helped identify my mistake.
clang (trunk): https://godbolt.org/z/4999Gj5dP
gcc (trunk): https://godbolt.org/z/Md6rMcexj
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs