This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/66326] Floating point exception with -mfpmath=387 and -fcilkplus.
- From: "ryan.burn at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 21 Oct 2015 11:38:16 +0000
- Subject: [Bug target/66326] Floating point exception with -mfpmath=387 and -fcilkplus.
- Auto-submitted: auto-generated
- References: <bug-66326-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66326
ryan.burn at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ryan.burn at gmail dot com
--- Comment #4 from ryan.burn at gmail dot com ---
I'm getting a similar problem testing with 6.0. Only the flags -mfpmath doesn't
seem to make a difference for the case I'm testing. But it runs successfully
with -O1 or above but fails with -O0. Not sure which particular option is
causing the problem.
Here's the code I'm testing with
///////////////////////////////////////////////////////////////////////////
#include <cilk/cilk.h>
#include <vector>
#include <random>
template <class T>
void do_not_optimize_away(T&& x) {
asm volatile("" : "+r"(x));
}
const int N = 1'000'000;
auto compute() {
std::vector<double> v(N);
auto rng = std::mt19937{std::random_device{}()};
std::uniform_real_distribution<double> dist(0, 1);
for (int i = 0; i < N; ++i) v[i] = std::log(std::sqrt(dist(rng)));
return v;
}
int main() {
std::vector<double> v1, v2, v3;
cilk_spawn [&] { v1 = compute(); }();
cilk_spawn [&] { v2 = compute(); }();
v3 = compute();
do_not_optimize_away(v1.data());
do_not_optimize_away(v2.data());
do_not_optimize_away(v3.data());
return 0;
}
///////////////////////////////////////////////////////////////////////////
// O1 level - good
rnburn@localhost ~/test/gcc_cilk $ /home/rnburn/local/bin/g++ -std=c++1z -O1
-fcilkplus -std=c++14 -march=haswell t2.cpp
rnburn@localhost ~/test/gcc_cilk $ ./a.out
// O0 level - fails
rnburn@localhost ~/test/gcc_cilk $ /home/rnburn/local/bin/g++ -std=c++1z -O0
-fcilkplus -std=c++14 -march=haswell t2.cpp
rnburn@localhost ~/test/gcc_cilk $ ./a.out
Floating point exception