[Bug c/82296] Warn for code removal due to "code never accesses array out of bounds" assumption

2017-09-25 Thread lundril at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82296 --- Comment #6 from Ingo --- > https://www.securecoding.cert.org/confluence/display/c/ARR30-C.+Do+not+form+or+use+out-of-bounds+pointers+or+array+subscripts Just out of curiosity: I am not able to find any of that in the ANSI/ISO C89 standard. T

[Bug c/82296] Warn for code removal due to "code never accesses array out of bounds" assumption

2017-09-22 Thread lundril at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82296 --- Comment #3 from Ingo --- Just to be sure: On a real machine this code is certainly not "undefined behavior", because gMyUnion.numbers[ARRAYSIZE] aliases gMyUnion.dummy[ARRAYSIZE] and gMyUnion.dummy[ARRAYSIZE] is a valid memory location. So

[Bug c/82296] New: Wrong code with optimization -O2

2017-09-22 Thread lundril at gmx dot de
Assignee: unassigned at gcc dot gnu.org Reporter: lundril at gmx dot de Target Milestone: --- Created attachment 42226 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42226&action=edit Compiling this code results in assembler which translates to "return 1;" To repro