[Issue 14482] New: [SPEC] Goto's into catch blocks should be an error
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Apr 23 02:23:38 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14482
Issue ID: 14482
Summary: [SPEC] Goto's into catch blocks should be an error
Product: D
Version: D1 & D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
It is illegal for a goto to enter a try or finally block in D. For consistency
it should also be illegal to enter a catch block via goto also.
GDC has been emitting an error since 2010, but DMD will happily continue to
accept such code.
----
Previous ML discussions:
http://forum.dlang.org/post/j4m10o$cu6$1@digitalmars.com
http://forum.dlang.org/post/qwifroariomkblyxnbdw@forum.dlang.org
----
Previous bug report which the fix was to disallow goto into TryStatement's.
https://issues.dlang.org/show_bug.cgi?id=4655
This error is not documented as far as I can see (it should be!)
----
Previous bug report which introduced an error for goto's into catch blocks only
if an initialisation was skipped.
https://issues.dlang.org/show_bug.cgi?id=602
----
What the specification has to say about 'finally' blocks:
"A FinallyStatement may not exit with a goto, break, continue, or return; nor
may it be entered with a goto."
-- http://dlang.org/statement.html#TryStatement
Reasoning for this (Quote from Walter in first ML link above):
"On a related note, doing a goto into a finally block is pretty problematic to
support because it's actually a mini-function."
In a way, GDC is exactly the same as DMD here, but also with try and catch
blocks. The difference being that it's not a function, it is treated as an
isolated area/block that is inaccessible from the outside.
----
--
More information about the Digitalmars-d-bugs
mailing list