This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/82296] Warn for code removal due to "code never accesses array out of bounds" assumption
- From: "lundril at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 Sep 2017 15:21:49 +0000
- Subject: [Bug c/82296] Warn for code removal due to "code never accesses array out of bounds" assumption
- Auto-submitted: auto-generated
- References: <bug-82296-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82296
--- Comment #6 from Ingo <lundril at gmx dot de> ---
> 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. That might be,
because I am not familiar where to find that in the C89 standard (I am
definitely not familiar with any of the formal C standard documents).
I also noticed that if I compile the example with
gcc -std=c89 -O2 -S gcc_check.c
I also get assembler code which basically implements "return 1;".
So does that mean gcc will always define "undefined behavior" according to the
C-2011 standard, even if you use "-std=c89" ?
What happens when the standard committee release a more recent version of the C
standard ?
Will the upcoming versions of GCC then use the updated definitions of
"undefined behavior" from the upcoming C standards definition and thus produce
non working code for any source code, which was not able to look into the
future and guessing what the C standards committee might deem "undefined
behavior" in the future ?