D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19685 - Nested aggregate overlaps not detected
Summary: Nested aggregate overlaps not detected
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-02-18 21:53 UTC by Walter Bright
Modified: 2019-02-24 18:25 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2019-02-18 21:53:41 UTC
Regression introduced by https://github.com/dlang/dmd/pull/9288

kinke writes:

some overlapping fields in the following example apparently don't get their `VarDeclaration.overlapped` flag set:


struct SWithUnion
{
    char c;
    S nested;

    union
    {
        struct { ubyte ub = 6; ushort us = 33; align(8) ulong ul_dummy = void; ulong last = 123; }
        struct { uint ui1; uint ui2 = 84; ulong ul = 666; }
    }
}
Comment 1 kinke 2019-02-18 23:30:57 UTC
https://run.dlang.io/is/p9cpXq:

```
struct S
{
    union
    {
        struct { int a = 123; }
        struct { int b = 456; }
    }
}

void main()
{
    S s;
    assert(s.b == 123);
}
```

Compiles successfully with 2.085.0-beta1, earlier versions rightfully complain:

Error: overlapping default initialization for field b and a
Error: overlapping default initialization for field a and b
Comment 2 Dlang Bot 2019-02-19 00:38:59 UTC
@Basile-z created dlang/dmd pull request #9373 "fix issue 19685 - Revert "aggregate, reduce the complexity of the loo…" fixing this issue:

- fix issue 19685 - Revert "aggregate, reduce the complexity of the loop checking the overlapped fields"
  
  This reverts commit 2ada2803f40cb59e4528dfadcf824d24e269d1f5.

https://github.com/dlang/dmd/pull/9373
Comment 3 Dlang Bot 2019-02-24 16:59:49 UTC
@MartinNowak created dlang/dmd pull request #9387 "Merge remote-tracking branch 'upstream/stable' into merge_stable" fixing this issue:

- Merge pull request #9373 from Basile-z/issue-19685
  
  fix issue 19685 - Revert "aggregate, reduce the complexity of the loo…
  merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>

https://github.com/dlang/dmd/pull/9387
Comment 4 Dlang Bot 2019-02-24 18:25:54 UTC
dlang/dmd pull request #9387 "Merge remote-tracking branch 'upstream/stable' into merge_stable" was merged into master:

- 1ed87aae3546f4d71df1d9e2e85c93d29d07a2b0 by The Dlang Bot:
  Merge pull request #9373 from Basile-z/issue-19685
  
  fix issue 19685 - Revert "aggregate, reduce the complexity of the loo…
  merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>

https://github.com/dlang/dmd/pull/9387