Reputation: 21
I've got a floating point exception in huge application after some changes. I tried to comment my changes and found that FPE happens when I enable one simple function call.
api::getMaxSize();
which simply returns value. looks like this
int api::getMaxSize() { return 536870912; };
This is static member function. When I move this to header file everything works fine. I'm confused, what can be the reson? Looks like API is in another module and linked as dynamic library, but how can this cause a problem?
added
There is function maxBox() which is template and implemented in api.h
header file.
This function calls getMaxSize()
template <typename T>
static rectangle<T> maxBox()
{
return rectangle<T>(
getMinSize(), getMinSize(),
getMaxSize(), getMaxSize()
);
}
here is the calling code
if (!api::maxBox<double>().contains(box * scale)) { /* api::getMaxSize(); */ }
If I enable getMaxSize() call the program starts throwing FPE, but getMaxSize() is actually never called.
added
Found FPE in box * scale
, can't understand why it was working without getMaxSize()
call, but however the problem is solved. Thanks to everybody.
Thanks in advance.
Upvotes: 2
Views: 1185
Reputation: 56956
Floating point exceptions (actually signals) are raised for different reasons. The main ones are:
As you can see, they have nothing to do with floating point numbers ! The name is historical and cannot be changed without breaking a lot of source code (there is a SIGFPE
constant in <signal.h>
).
It can be here that GetMaxSize
returns a value which is not representable by a int
.
Upvotes: 1