This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/69249] New: Array-boundary offending code is silently discarded without warnings
- From: "ilia.kolominsky at intel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 12 Jan 2016 16:11:24 +0000
- Subject: [Bug c/69249] New: Array-boundary offending code is silently discarded without warnings
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69249
Bug ID: 69249
Summary: Array-boundary offending code is silently discarded
without warnings
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ilia.kolominsky at intel dot com
Target Milestone: ---
Hello team!
Recently, our team upgraded to gcc ver 4.8.2 (from 4.7.3) and started to
experience incorrect behavior in various components of the software product.
We figured that some our components contain bogus code that violate array
bounds, which go unnoticed during the compilation and the runtime.
The issue with the newer gcc is that such code is completely discarded from the
resulting object, silently, without warnings.
It can be seen clearly using the following simple code that I tested using
https://gcc.godbolt.org/
#include <stdio.h>
#define ARR_SIZE 64
char arr1[ARR_SIZE];
char arr2[ARR_SIZE];
int main(int argc, char * argv[])
{
int i = 0;
scanf("%s",arr1);
scanf("%s",arr2);
while ((arr1[i] != arr2[i]) && i <= ARR_SIZE) /* Array bounds violation */
{
i++;
}
if (i == ARR_SIZE)
{
return 0xaa55;
}
return 0;
}
The compilation options are: -O3 -Wall
It can be seen from the resulting assembly code that all the code bellow the
second scanf is simply discarded and main always returns 0.
Despite -Wall, no warning are produced related to this issue...
Regards,
Ilia Kolominsky