[Issue 3476] New: C-style initializer for structs must be disallowed for structs with a constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 5 13:55:03 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3476

           Summary: C-style initializer for structs must be disallowed for
                    structs with a constructor
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrei at metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei at metalanguage.com> 2009-11-05 13:55:02 PST ---
struct S {
    int a;
    this(int) {}
}

S s = { 1 };

This code should not compile. The presence of the constructor means S's author
wants to guard some invariant. The C-style constructor may initialize the
object to an arbitrary value.

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


More information about the Digitalmars-d-bugs mailing list