Consensus on goto's into catch blocks

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jun 13 10:50:09 PDT 2013


On Thu, Jun 13, 2013 at 07:35:39PM +0200, Iain Buclaw wrote:
> Can someone remind me again what was last agreed when I brought this
> up?
> 
> I seem to recall that this should be disallowed as is practically
> always a bug, also, and it skips any initialisation of the exception
> object. (See: http://dlang.org/statement.html - "It is illegal for a
> GotoStatement to be used to skip initializations.")
> 
> Current failing test I want to have removed from the test suite.
> 
> test/runnable/eh.d:
> void test8()
> {
>   int a;
>   goto L2;    // gdc Error: cannot goto into catch block
> 
>   try {
>       a += 2;
>   }
>   catch (Exception e) {
>       a += 3;
> L2: ;
>       a += 100;
>   }
>   assert(a == 100);
> }
[...]

Hmph, how did this test end up in test/runnable? What if after L2, we
try to deference e? I can't see any way this code can even be remotely
valid. How did this end up in the test suite?? (Or is this supposed to
test whether the compiler is able to ascertain that e is not referenced
after L2? Does DMD even do that kind of analysis?)


T

-- 
"Holy war is an oxymoron." -- Lazarus Long


More information about the Digitalmars-d mailing list