Does the C++ Standard allow the addition of two integers (fundamental type int) to throw a C++ exception? -


does standard allow this?

i don't think does. does. need intelligent people prove him wrong.

yes, does. overflow of signed integers undefined behavior, happen (including exception being thrown).

as side note, must unlikely happen (yet possible) implementations; c++11 standard mentions in note paragraph 5/4:

if during evaluation of expression, result not mathematically defined or not in range of representable values type, behavior undefined. [ note: existing implementations of c++ ignore integer overflows. treatment of division zero, forming remainder using 0 divisor, , floating point exceptions vary among machines, , adjustable library function. —end note ]

as hvd mentions in comments, however, implementations allow provide custom handlers integer overflow, , handlers may throw.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -