This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/4389: Improper constant folding



>Number:         4389
>Category:       c
>Synopsis:       Improper constant folding
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 24 22:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     mac@culver.net
>Release:        unknown-1.0
>Organization:
>Environment:
cc -v -save-temps vvv.c                                     ~/September.2001
Using builtin specs.
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
 /usr/libexec/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=91 -Di386 -D__NetBSD__ -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -D__i386__ -D__NetBSD__ -D__ELF__ -D__KPRINTF_ATTRIBUTE__ -D__i386 -Asystem(unix) -Asystem(NetBSD) -Acpu(i386) -Amachine(i386) vvv.c vvv.i
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
End of search list.
 /usr/libexec/cc1 vvv.i -quiet -dumpbase vvv.c -version -o vvv.s
GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i386-netbsd) compiled by GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release).
 as -o vvv.o vvv.s
 /usr/libexec/collect2 -m elf_i386 -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so /usr/lib/crt0.o /usr/lib/crtbegin.o -L/usr/libexec vvv.o -lgcc -lc -lgcc /usr/lib/crtend.o
>Description:
Improper constant folding; ends up causing segfault

In the program, below, in the last printf(), the address
of matrix[N-1][N-1] is improperly computed.
>How-To-Repeat:
#define N 10000
float matrix[N][N];
void main( void )
{
  int i=9999;
  matrix[i][i] = (float)random();
  printf( "The last element is: %12.10f\n", matrix[i][i] );
  printf( "The last element is: %12.10f\n", matrix[N-1][N-1] );
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]