[Issue 4082] nothrow main() can throw
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 15 01:06:22 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4082
--- Comment #2 from Marco Leise <Marco.Leise at gmx.de> 2012-08-15 01:06:15 PDT ---
Since it all applies to FuncDeclaration::semantic3(...), I'll add this case:
void b(Test t) nothrow {
}
struct Test {
~this() {
throw new Exception("i am throwing");
}
}
The compiler checks for thrown exceptions or - more generally - the block exit
state in two cases:
1)
https://github.com/D-Programming-Language/dmd/blob/869d6dbffc4ab85576a39f19085ab7270ae2191e/src/func.c#L1301
2)
https://github.com/D-Programming-Language/dmd/blob/869d6dbffc4ab85576a39f19085ab7270ae2191e/src/func.c#L1577
(2) handles the case of appending destructor calls for structs passed by value
to a function. Functions without return/throw/etc. just get the destructors
appended, while all others get them wrapped in a try-finally clause to ensure
they are called. Since destructors may throw and the function isn't checked
again after their addition, nothrow doesn't necessarily hold here. That's the
case in the above example.
(1) is the normal check if a function is nothrow, but throws. blockExit()
determines the way any code block exits. This may be through 'return', 'throw',
'goto', halt (assert(0)?), 'break', 'continue' or the execution may
unconditionally succeed or 'fall through'. That's my understanding anyways.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list