Re:Apple's SSL/TLS bug
by eliasmacpherson on Saturday February 22, 2014 @11:37AM
(#7282562)
Ok for example:
int e;
int update() { throw &e; }
the & is the one character - it's a typo - only catch(...) will catch it.
Well, since you're throwing an int-pointer then catch(int*) should also catch it quite happily.
I guess you mean there will only be a catch(int) in addition to catch(...) so in that aspect you're right of course.
Still, I would think taking the address of something you throw should ring quite a few warning bells as opposed to merely a missing ref (&) in the catch handler. Similarly to "return &e" which would also be suspicious and require an extra look or two.
Re:Apple's SSL/TLS bug
by eliasmacpherson on Saturday February 22, 2014 @12:18PM
(#7282708)
My point being it would raise far less warning bells than an unguarded goto.
If you always throw by value (and not by pointer) then it does not matter if you catch by value or by reference, the catch block will be activated either way. The only issue is possible slicing if you throw a derived instance and catch a base class type. You might lose error information that way, but the program will not crash due to an uncaught exception.