digitalmars.D.learn - Throw in a pre-condition of a nothrow function
- bearophile (18/18) Mar 08 2013 Currently this code compiles:
- Maxim Fomin (2/2) Mar 08 2013 That's a bug. Interesting point here is whether it is a
- Rob T (8/9) Mar 08 2013 [...]
- bearophile (4/6) Mar 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9669
Currently this code compiles: void foo() nothrow in { throw new Exception(null); } body { } void main() { foo(); } Then at runtime throws: object.Exception test.d(3) --------- 0x00402044 in nothrow void test.foo() at ... ... Is this good? Isn't the "nothrow" tag used by the compiler to better optimize functions? Bye, bearophile
Mar 08 2013
That's a bug. Interesting point here is whether it is a regression or not.
Mar 08 2013
On Friday, 8 March 2013 at 19:39:47 UTC, bearophile wrote:Currently this code compiles:[...] Nice edge case to test the compiler with. Definitely looks like a bug. It should not compile given the nothrow attrib. If it was throwable, what to do about throwing a null reference is an interesting question. --rt
Mar 08 2013
Rob T:Definitely looks like a bug. It should not compile given the nothrow attrib.http://d.puremagic.com/issues/show_bug.cgi?id=9669 Bye, bearophile
Mar 08 2013