This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
other/7118: Compiler generates code that cannot be executed.
- From: mhdecoursey at netscape dot net
- To: gcc-gnats at gcc dot gnu dot org
- Cc: markhdecoursey at aol dot com
- Date: 25 Jun 2002 15:15:26 -0000
- Subject: other/7118: Compiler generates code that cannot be executed.
- Reply-to: mhdecoursey at netscape dot net
>Number: 7118
>Category: other
>Synopsis: Compiler generates code that cannot be executed.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jun 25 08:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Mark DeCoursey
>Release: 2.9-gnupro-99r1
>Organization:
>Environment:
>Description:
The following code compiles without error or warning,
and generates a program that will not run on my Sun Blade.
It crashes with a SEGV on first instruction.
The cause is obvious. In GDB, set a break on main. Before
executing any instructions, examine the values for a, b,
c, d, e, and f.
A single step in the debugger causes the SEGV.
Luckily I was able to find the problem with only an hour's
work. With a more complex program, I might have lost days.
int
main(
int argc,
char* argv[]
)
{
int a = 5;
int b = 6;
int c = 7;
int array[1000000];
int d = 8;
int e = 9;
int f;
f = a + b + c + d + e;
array[1] = f;
return( 0 );
}
>How-To-Repeat:
Compile the above code with -g. No header files are required.
>Fix:
I realize it may not be possible to test the system when
generating the program, but a warning should be issued when
an excessively large array is encountered.
The ideal of course would be to compute on installation what
the system could tolerate, and build that into a compiler
parameter.
But if wishes were compilers, beggars would write code, and
then where would we be?
>Release-Note:
>Audit-Trail:
>Unformatted: