[Issue 18708] New: Flow analysis in constructors not done correctly for if, ||, &&

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 2 21:24:28 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18708

          Issue ID: 18708
           Summary: Flow analysis in constructors not done correctly for
                    if, ||, &&
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

struct S { int y; @disable this(); }  // so construction is required

  class C
  {
    S s;

    this(S t)
    {
        if (bar(s = t)) foo(); // bug: Error: one path skips field s
    }

    this(S t, int i)
    {
        i || bar(s = t);  // bug: should give error
    }

    this(S t, int i, int j)
    {
        i && bar(s = t);  // bug: should give error
    }

    this(S t, int i, long j)
    {
        i ? bar(s = t) : i;   // good: Error: one path skips field s
    }

    this(S t, int i, long j)
    {
        i ? i : bar(s = t);   // good: Error: one path skips field s
    }
  }

  int bar(S s);
  int foo();

--


More information about the Digitalmars-d-bugs mailing list