Example code that triggers the bug on a variety of machines all running gcc
4.1.2 and higher.

#include <stdio.h>
inline double sqr(double x){
  return x*x;
}
int main(){
  double r;
  for(r=0.0;r<2.0;r+=1.0){
    printf("%e \n", sqr(sqr(sqr(sqr(sqr(r))))));
  }
  return 0;
}

/usr/libexec/gcc/i686-pc-linux-gnu/4.1.2/cc1 -v -Wall -O -o md md.c
The output of cc1 is:
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include
 /usr/include
End of search list.
 vprintf getchar fgetc_unlocked getc_unlocked getchar_unlocked putchar
fputc_unlocked putc_unlocked putchar_unlocked feof_unlocked ferror_unlocked sqr
main
Analyzing compilation unitPerforming intraprocedural optimizations
Assembling functions:
 sqr main^C


-- 
           Summary: gcc fills up memmory (and crashes) with tree
                    Optimizations
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: m dot hermes at uu dot nl
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41306

Reply via email to