Skip to content

Commit

Permalink
fix nim-lang#10305 nim cpp is now nan-correct at CT
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jan 15, 2019
1 parent 9e68b2c commit 6d486c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ compiler gcc:
result = (
name: "gcc",
objExt: "o",
optSpeed: " -O3 -ffast-math ",
optSize: " -Os -ffast-math ",
optSpeed: " -O3 ",
optSize: " -Os ",
compilerExe: "gcc",
cppCompiler: "g++",
compileTmpl: "-c $options $include -o $objfile $file",
Expand All @@ -88,8 +88,8 @@ compiler nintendoSwitchGCC:
result = (
name: "switch_gcc",
objExt: "o",
optSpeed: " -O3 -ffast-math ",
optSize: " -Os -ffast-math ",
optSpeed: " -O3 ",
optSize: " -Os ",
compilerExe: "aarch64-none-elf-gcc",
cppCompiler: "aarch64-none-elf-g++",
compileTmpl: "-w -MMD -MP -MF $dfile -c $options $include -o $objfile $file",
Expand Down
3 changes: 3 additions & 0 deletions doc/nimc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ complete list.
Define Effect
====================== =========================================================
``release`` Turns off runtime checks and turns on the optimizer.
More aggressive optimizations are possible, eg:
``--passC:-ffast-math`` (but see issue #10305)
``--stacktrace:off``
``useWinAnsi`` Modules like ``os`` and ``osproc`` use the Ansi versions
of the Windows API. The default build uses the Unicode
version.
Expand Down
16 changes: 16 additions & 0 deletions tests/float/tfloatnan.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,19 @@ echo "Nim: ", f32, " (float)"

let f64: float64 = NaN
echo "Nim: ", f64, " (double)"


proc fun() =
# issue #10305
# with `-O3 -ffast-math`, generated C/C++ code is not nan compliant
# user can pass `--passC:-ffast-math` if he doesn't care.
let a1 = 0.0
let a = 0.0/a1
let b1 = a == 0.0
let b2 = a == a
doAssert not b1
doAssert not b2

static: fun()
fun()

0 comments on commit 6d486c1

Please sign in to comment.