Bug 4101 – [tdpl] DMD doesn't give error when goto skips initialization
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-04-17T13:23:00Z
Last change time
2014-02-15T02:45:49Z
Keywords
accepts-invalid, TDPL
Assigned to
nobody
Creator
jlquinn
Comments
Comment #0 by jlquinn — 2010-04-17T13:23:00Z
The following code should not compile but does with DMD 2.041.
The goto skips several initializations.
void foo() {
goto L0;
int b;
struct S { int a; this(int c) { a=c; } }
S s = S(5);
class C { int a; }
C c = new C;
L0: ;
s.a++;
c.a++;
}
Comment #1 by clugdbug — 2010-04-17T23:56:47Z
Is this the same as bug 602?
Comment #2 by jlquinn — 2010-04-19T17:56:44Z
(In reply to comment #1)
> Is this the same as bug 602?
It's related. There's an implicit init being accepted here. However, there are 2 explicit inits being ignored as well, and bug 602 doesn't report that.
Comment #3 by andrei — 2011-12-18T18:20:26Z
Another example:
unittest
{
goto target;
int x = 10;
target:
int y = x;
}
TDPL claims that that can't happen.
Comment #4 by code — 2013-10-31T10:15:09Z
*** This issue has been marked as a duplicate of issue 602 ***