[Issue 21229] New: [REG 2.080.2] Constructor flow analysis doesn't understand unions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Sep 6 23:34:38 UTC 2020
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 at puremagic.com
Reporter: snarwin+bugzilla at 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
*/
--
More information about the Digitalmars-d-bugs
mailing list