It doesn't throw any error in Visual Studio 2008. .......What setting one has to change so that it will show runtime error in VS 2008.....Code:int main()
{
int z=0;
int i=1/z;
cout<<i;
}
It doesn't throw any error in Visual Studio 2008. .......What setting one has to change so that it will show runtime error in VS 2008.....Code:int main()
{
int z=0;
int i=1/z;
cout<<i;
}
Perhaps MSVC catches that particular error when you compile in debug mode. Or perhaps it's only an error when you do floating-point division by zero.
On Windows, FPU exceptions are normally disabled. A floating point divide-by-zero results in infinity, not an exception. If you want the exceptions you need to turn them on explicitly by calling _controlfp()
For integer divide-by-zero an exception is always generated, because unlike IEEE floats there is no way to represent "infinity" and so there is no possible valid result of the division. An exception is the only choice.
According to what the OP is reporting, I suspect the actual code was using floats instead of integers. There is no way for an integer division to result in "infinity." And I get very reliable exceptions for that integer divide-by-zero. I think the OP is confused.
Damn you beat me to it brew :D