www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19030] New: CTorFlow checking is too aggressive and only


          Issue ID: 19030
           Summary: CTorFlow checking is too aggressive and only checks
                    whether a this call is present
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

https://issues.dlang.org/show_bug.cgi?id=18719 introduced a regression as it
only checks whether a this() call is present, but not what the this call
actually does.
For example, this slightly modified example from 18719 no produces an error
even though it sets x only once:

struct S
    int x = -1;
    this(int y) immutable
        x = y;
        import std.stdio;
        writeln("Ctor called with ", y);
    void opAssign(int) immutable;

class C
    S x;
    this() immutable
        this(42); /* Initializes x. */
        x = 13; /* Breaking immutable, or ok? */
    this(int x) immutable

Jun 27 2018