[Bug c/87060] New: Condition check is optimized out for volatile unsigned char / short
yso at melexis dot com
gcc-bugzilla@gcc.gnu.org
Wed Aug 22 15:13:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87060
Bug ID: 87060
Summary: Condition check is optimized out for volatile unsigned
char / short
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: yso at melexis dot com
Target Milestone: ---
Compilers from http://gcc.godbolt.org/ are used to reproduce the issue.
Compiler: x86-64 gcc (trunk); gcc (GCC-Explorer-Build) 9.0.0 20180821
(experimental)
Options: -Os
Test code:
```
volatile unsigned char u8;
void test_u8 (void)
{
if (u8 + 1) { u8 = 1; }
}
```
Disassembly:
```
test_u8:
mov al, BYTE PTR u8[rip]
mov BYTE PTR u8[rip], 1
ret
```
Condition check is optimized out, while unsigned overflow is perfectly
legitimate operation.
- also can be reproduced in gcc 8/7/6/5 and 4 (after 4.1.2)
- also with unsigned short type
More information about the Gcc-bugs
mailing list