digitalmars.D.bugs - [Issue 21229] New: [REG 2.080.2] Constructor flow analysis doesn't
- d-bugmail puremagic.com (51/51) Sep 06 2020 https://issues.dlang.org/show_bug.cgi?id=21229
https://issues.dlang.org/show_bug.cgi?id=21229 Issue ID: 21229 Summary: [REG 2.080.2] Constructor flow analysis doesn't understand unions Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com Example program: --- struct NeedsInit { int n; disable this(); } union U { NeedsInit a; } struct S { U u; this(NeedsInit arg){ u.a = arg; } } --- Compiler output, from run.dlang.io: Up to 2.060 : Failure with output: ----- onlineapp.d(15): Error: can only initialize const member a inside constructor onlineapp.d(15): Error: can only initialize const member a inside constructor onlineapp.d(15): Error: constructor onlineapp.S.this field u must be initialized in constructor ----- 2.061 to 2.080.1: Success and no output Since 2.081.2: Failure with output: onlineapp.d(15): Error: field `u` must be initialized in constructor This appears to be a known bug, since there is a comment about unions in `dmd.semantic3.Semantic3Visitor.visit(FuncDeclaration)`: /* Current bugs in the flow analysis: * 1. union members should not produce error messages even if * not assigned to * 2. structs should recognize delegating opAssign calls as well * as delegating calls to other constructors */ --
Sep 06 2020