D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4101 - [tdpl] DMD doesn't give error when goto skips initialization
Summary: [tdpl] DMD doesn't give error when goto skips initialization
Status: RESOLVED DUPLICATE of issue 602
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, TDPL
Depends on:
Blocks:
 
Reported: 2010-04-17 13:23 UTC by Jerry Quinn
Modified: 2014-02-15 02:45 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2010-04-17 13:23:00 UTC
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 Don 2010-04-17 23:56:47 UTC
Is this the same as bug 602?
Comment 2 Jerry Quinn 2010-04-19 17:56:44 UTC
(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 Andrei Alexandrescu 2011-12-18 18:20:26 UTC
Another example:

unittest
{
      goto target;
      int x = 10;
      target:
      int y = x;
}

TDPL claims that that can't happen.
Comment 4 Martin Nowak 2013-10-31 10:15:09 UTC

*** This issue has been marked as a duplicate of issue 602 ***