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.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
HOPE YOU UNDERSTAND.......
By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior
PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition
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.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}