impossible constraint violation for value cast to unsigned char
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Won't Fix
|
High
|
Joey Ye |
Bug Description
The reduced example below produces a diagnostic when a value in the I constraint range is explicitly cast to unsigned char. The diagnostic does not appear if the value is not cast. This is reduced from a case where 0x80 is an enumeration constant.
Work-around is to use "0xFF & value" rather than "(unsigned char)value".
lilith[1173]$ cat x.c
__attribute_
static void service(void) {
__asm( "svc %0\n" "bx r14" : : "I" ((unsigned char)0x80) : "r0" );
}
int main() {
service();
}
lilith[1174]$ arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 x.c
x.c: In function 'service':
x.c:3:3: warning: asm operand 0 probably doesn't match constraints
__asm( "svc %0\n" "bx r14" : : "I" ((unsigned char)0x80) : "r0" );
^~~~~
x.c:3:3: error: impossible constraint in 'asm'
Present in following and several earlier releases on Linux.
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-
Changed in gcc-arm-embedded: | |
status: | New → In Progress |
Changed in gcc-arm-embedded: | |
status: | In Progress → Won't Fix |
I've reported the bug in [1]. I have a patch that works for this testcase which I'm currently testing.
[1] https:/ /gcc.gnu. org/bugzilla/ show_bug. cgi?id= 85344
Best regards.