[Issue 3020] No description is given why function may not be nothrow

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 29 05:31:38 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3020



--- Comment #7 from Don <clugdbug at yahoo.com.au> 2010-10-29 05:30:34 PDT ---
(In reply to comment #5)
> Out of memory errors should be allowed inside nothrow.

Good. I think so too. That will make nothrow much more useful.
In the existing compiler, they are disallowed. 
( void foo() nothrow { auto x = new int; }  won't compile).
I just added error messages to specify why it was being disallowed.

It sounds as though the check for nothrow violations should be separated from
the code which determines if a statement can throw. That is, for 'new' and for
asm, we assume that it can throw. But, if it's in a nothrow function, we trust
the programmer.
Then, what happens if an out of memory condition happens in a nothrow function?
Is the program simply terminated?

> 
> Also, I suspect it would be good to disallow:
> 
> try
> {
>    ...
> }
> catch (Exception e)
> {
>    /* nothing here */
> }
> 
> where all exceptions are swallowed and ignored. This kind of thing happens in
> Java to work around exception specifications, but I don't see a need for it
> here. Of course, there would still be ways to swallow & ignore (just put in a
> call to a do-nothing function), but such shouldn't be easy.
> 
> What do you think?

Dunno. It's certainly bad style.

-- 
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