throw "fubar" - Fragen zum Standard
-
Gegeben sei
try { throw "abc"; } catch (char [4]) { cout << "caught!\n"; }
meinem verständnis nach sollte die exception nicht gefangen werden, da der handler aber nur für char* zulässig ist (nach 15.3/2 *nicht* für char[4]).
allerdings sagt 15.1/3, dass für ein string-literal in diesem kontext niemals die konvertierung in den entsprechenden char-(non-const)-zeiger geschieht. meine frage: ist das temporary nun ein array char[4] oder ein zeiger auf const-char?
-
Ich denke mal, dass das hier passiert:
ISO/IEC 14882:2003 schrieb:
A throw-expression initializes a temporary object, called the exception object, the type of which is determined by removing [...] and adjusting the type from “array of T” or [...] to “pointer to T” or [...]