[GHC] #4321: Unexpected stack overflow prevented by superfluous type annotation

GHC cvs-ghc at haskell.org
Wed Oct 27 11:48:54 EDT 2010


#4321: Unexpected stack overflow prevented by superfluous type annotation
---------------------------+------------------------------------------------
  Reporter:  bjpop         |          Owner:                  
      Type:  bug           |         Status:  new             
  Priority:  normal        |      Milestone:                  
 Component:  Compiler      |        Version:  6.13            
Resolution:                |       Keywords:                  
  Testcase:  T4321         |      Blockedby:                  
Difficulty:                |             Os:  Unknown/Multiple
  Blocking:                |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  |  
---------------------------+------------------------------------------------

Comment(by daniel.is.fischer):

 I've no idea. compiling
 {{{
 #include <stdio.h>
 #include <stdlib.h>

 static double integrate(int n, double h){
     int i;
     double x, sm = 0.0;
     for(i = 1; i <= n; ++i){
         x = h*((double)i-0.5);
         sm += 4.0 / (1.0 + x*x);
     }
     return h*sm;
 }

 int main(int argc, char *argv[]){
     int num = 1000000;
     if (argc > 1){
         num = atoi(argv[1]);
     }
     printf("%.16f\n",integrate(num,1.0/num));
     return EXIT_SUCCESS;
 }
 }}}
 $ gcc -ffloat-store -o vbjpi vbjpi.c[[BR]]
 $ ./vbjpi[[BR]]
 3.1415926535897634

 both, with gcc-4.3.2 and gcc-4.4.1, also with icc -O0. So it seems to be
 something my C compilers do.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4321#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list