Skip to content

Commit

Permalink
Merge pull request #5159 from ibuclaw/overlapping
Browse files Browse the repository at this point in the history
Refactor detection of overlapping fields in StructInitializer semantic
  • Loading branch information
9rnsr committed Oct 7, 2015
2 parents 94d9694 + 221b3e8 commit 344630e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/init.d
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ public:
for (size_t j = 0; j < nfields; j++)
{
VarDeclaration v2 = sd.fields[j];
bool overlap = (vd.offset < v2.offset + v2.type.size() && v2.offset < vd.offset + vd.type.size());
if (overlap && (*elements)[j])
if (vd.isOverlappedWith(v2) && (*elements)[j])
{
error(loc, "overlapping initialization for field %s and %s", v2.toChars(), vd.toChars());
errors = true;
Expand Down

0 comments on commit 344630e

Please sign in to comment.