[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] 'zero_test.cpp' crashes clang++ with '-O2 -ffp-model=strict'
From: |
Greg Chicares |
Subject: |
[lmi] 'zero_test.cpp' crashes clang++ with '-O2 -ffp-model=strict' |
Date: |
Sat, 25 Jun 2022 20:22:18 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 |
[effective workaround given below]
Using...
$ clang++ --version
Debian clang version 13.0.1-6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
...this crashes clang++:
$ clang++ -c -I . -fPIC -ffp-model=strict -std=c++20 -O2 -Wno-string-plus-int
zero_test.cpp -ozero_test.o 2>&1 |less -S
Moving '-ffp-model=strict' to the end or the beginning, it still crashes:
$ clang++ -c -I . -fPIC -std=c++20 -O2 -Wno-string-plus-int zero_test.cpp
-ozero_test.o -ffp-model=strict 2>&1 |less -S
$ clang++ -ffp-model=strict -c -I . -fPIC -std=c++20 -O2 -Wno-string-plus-int
zero_test.cpp -ozero_test.o 2>&1 |less -S
Removing '-ffp-model=strict' keeps it from crashing:
$ clang++ -c -I . -fPIC -std=c++20 -O2 -Wno-string-plus-int zero_test.cpp
-ozero_test.o 2>&1 |less -S
but I really do want IEEE 754 behavior: without '-ffp-model=strict',
some unit test told me that 1.5 rounded downward is 2.0, a result
with which I must disagree.
I don't actually want to unmask floating-point exceptions, so this is
the best workaround I can come up with:
clang++ -c -I . -Woverriding-t-option -ffp-model=strict
-ffp-exception-behavior=ignore -Wno-overriding-t-option -fPIC -std=c++20 -O2
-Wno-string-plus-int zero_test.cpp -ozero_test.o 2>&1 |less -S
(surrounding the '-ffp' options with flags to toggle the warning
that they jointly engender).
I suppose I could try unmasking floating-point exceptions early
(say, in static initialization), but I wouldn't expect that to
forestall a compile-time diagnostic.
- [lmi] 'zero_test.cpp' crashes clang++ with '-O2 -ffp-model=strict',
Greg Chicares <=