Skip to content

Program produces different output when compiled with -O

When compiled and run as

ghc Subtlety.hs
Subtlety

the attached program generates the correct output of

Just (Vec3 0.0 0.0 1.0)

but when compiled and run using

ghc -O Subtlety.hs
Subtlety

the program's output is

Just (Vec3 0.0 0.9805806756909202 0.19611613513818404)

Furthermore, subtle changes to the source code (like removing the strictness on the Vec3 type's fields) can alter the behavior of the compiled program.

I am using GHC 7.8.3 x86-64 from Haskell Platform 2014.2.0.0 RC2 on Windows 8.

Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information