Why isn't C++ catching this exception? -
i have next code extracting string out of buffer array. works fine. however, length variable determined @ runtime, if go out of bound, exception occur. of course, code can adjusted check if length variable (in relation offset variable) falls within boundaries. though i'm curious why next code not work, exception seems fly through try-catch statement (and caught debugger).
try { string value(&buffer[offset], length); // ... } grab (exception& e) { // ... } grab (...) { // ... }
running on windows 7 64bit, msvcr compiled.
accessing buffer
array beyond bounds undefined behaviour. there no requirement c++ exception thrown in case. seek instantiating string outside seek block , you'll see sure whether exception thrown.
c++ exception
No comments:
Post a Comment