#952: gcc should be passed the -fwrapv flag
----------------------+-----------------------------------------------------
 Reporter:  simonmar  |          Owner:          
     Type:  bug       |         Status:  reopened
 Priority:  normal    |      Milestone:  6.6.1   
Component:  Compiler  |        Version:  6.6     
 Severity:  normal    |     Resolution:          
 Keywords:            |     Difficulty:  Unknown 
 Testcase:            |   Architecture:  Multiple
       Os:  Multiple  |  
----------------------+-----------------------------------------------------
Changes (by simonmar):

  * resolution:  fixed =>
  * summary:  Floating point exception building HEAD with 6.6 => gcc should
              be passed the -fwrapv flag
  * status:  closed => reopened

Comment:

 re-opening.  After giving this some more thought, I realised that the
 Haskell report's meaning of "undefined" is different from the C language
 specification's meaning of "undefined", and that in fact `ghc -fvia-C` is
 behaving incorrectly here.

 Overflow of `Int` should return either `_|_` or an implementation-defined
 value, according to the Haskell report.  In the code affected by this bug,
 we were returning an implementation-defined value (2's complement
 wrapping) but a subsequent test on the value was returning an inconsistent
 answer; this is allowed by the C spec, but not by Haskell.

 The upshot is that I believe we should invoke gcc with `-fwrapv` where it
 is supported (gcc 3.4+).  This is more than required: it forces 2's
 complement wrapping behviour, but prevents the illegal optimisations that
 give rise to this bug.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/952>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to