Compile with:
g++ crash.cpp -O2
Crashes on:
g++ (Gentoo 4.3.2 p1.1) 4.3.2
g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
g++ (ubuntu current stable)
Steps to reproduce:
1. Make a file crash.cpp (contents below)
2. g++ crash.cpp -O2
3. ./a.out
Floating point exception
Source:
#include <iostream>
#include <fenv.h>
float g(const float& x)
{
float y = x;
if(y == 0.0f)
{
y=1.0f;
}
return x/y;
}
void f(const float &z)
{
if (z 0.0f)
{
float Unit2 = g(z);
std::cout << Unit2;
}
}
int main()
{
feenableexcept( FE_INVALID);
float a = 130.0f;
f(a);
return 0;
}
g++ crash.cpp -O2
Crashes on:
g++ (Gentoo 4.3.2 p1.1) 4.3.2
g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
g++ (ubuntu current stable)
Steps to reproduce:
1. Make a file crash.cpp (contents below)
2. g++ crash.cpp -O2
3. ./a.out
Floating point exception
Source:
#include <iostream>
#include <fenv.h>
float g(const float& x)
{
float y = x;
if(y == 0.0f)
{
y=1.0f;
}
return x/y;
}
void f(const float &z)
{
if (z 0.0f)
{
float Unit2 = g(z);
std::cout << Unit2;
}
}
int main()
{
feenableexcept( FE_INVALID);
float a = 130.0f;
f(a);
return 0;
}
Comment