$ cat multi-case
#! /usr/bin/perl

srand(0);

$last = 100 unless $last = shift;

for ($i=1; $i<=$last; $i++) {
    push(@lines, sprintf("    case(%d)\n     j = %d\n",$i, $last-$i));
}

for ($i=0; $i<=$last; $i++) {
    $j = int(rand($last));
    $temp = $lines[$i];
    $lines[$i] = $lines[$j];
    $lines[$j] = $temp;
}
print "program main\n";
print "  read (*,*) i\n";
print "  select case (i)\n";
print @lines;
printf "  end select\n";
print  "  print *,i,j\n";
print  "end\n";
$ perl multi-case 100000 > multi-case.f90
$ gfortran multi-case.f90

f951: out of memory allocating 1252087640 bytes after a total of 61874176 bytes
$ perl multi-case 5
program main
  read (*,*) i
  select case (i)
    case(3)
     j = 2
    case(4)
     j = 1
    case(2)
     j = 3
    case(1)
     j = 4
    case(5)
     j = 0
  end select
  print *,i,j
end
$ gfortran -v
Reading specs from /home/ig25/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure --prefix=/home/ig25 
--enable-languages=c,c++,f95
Thread model: posix
gcc version 4.0.0 20041208 (experimental)

-- 
           Summary: Out of memory with many select case statements
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Thomas dot Koenig at online dot de
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to