[Issue 602] Compiler allows a goto statement to skip an initalization

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 19 05:04:21 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=602



--- Comment #11 from yebblies <yebblies at gmail.com> 2013-11-20 00:04:20 EST ---
(In reply to comment #9)
> (In reply to comment #8)
> > but it requires all gotos to be resolved during semantic.
> 
> Is it a problem for possible implementations of computed gotos?

No.

As for this bug, I have implemented the semantics outlined in the specs for
most statements:
"It is illegal for a GotoStatement to be used to skip initializations"

This means the following will be illegal:

void main() {
    goto label;
    int x;
    label: {}
}

Even though x is never referenced after the label.

This is probably going to break a bunch of code that doesn't actually do
anything that bad.

An implementation that tracks the live ranges of variables is possible, but
much more complicated.  Doing it this way would also allow catching 'used
before set' bugs.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list