samedi 28 mars 2015

How can C++'s atoi() guarantee not to throw an exception if it allows undefined behavior?


I was reading this:


http://ift.tt/1s8FoD3


when I saw two sentences that make no sense to me towards the end.



this function never throws exceptions.



vs.



If str does not point to a valid C-string, or if the converted value would be out of the range of values representable by an int, it causes undefined behavior.



If the behavior of a bad parse is undefined, doesn't that mean all bets are off, and it's entirely possible for an exception to be raised? Or does this mean "undefined except that the runtime promises not to throw an exception"?




Aucun commentaire:

Enregistrer un commentaire