Skip to content

Commit

Permalink
fix Issue 17843 - -betterC struct with field generates references to …
Browse files Browse the repository at this point in the history
…TypeInfo
  • Loading branch information
WalterBright committed Nov 30, 2017
1 parent e58519e commit 1d2da66
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/ddmd/clone.d
Expand Up @@ -695,8 +695,9 @@ private bool needToHash(StructDeclaration sd)
}
if (tv.isfloating())
{
// This is necessray for:
// 1. comparison of +0.0 and -0.0 should be true.
/* This is necessary because comparison of +0.0 and -0.0 should be true,
* i.e. not a bit compare.
*/
goto Lneed;
}
if (tv.ty == Tarray)
Expand Down
9 changes: 6 additions & 3 deletions src/ddmd/dsymbolsem.d
Expand Up @@ -5473,9 +5473,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
buildOpAssign(sd, sc2);
buildOpEquals(sd, sc2);

sd.xeq = buildXopEquals(sd, sc2);
sd.xcmp = buildXopCmp(sd, sc2);
sd.xhash = buildXtoHash(sd, sc2);
if (global.params.useTypeInfo) // these functions are used for TypeInfo
{
sd.xeq = buildXopEquals(sd, sc2);
sd.xcmp = buildXopCmp(sd, sc2);
sd.xhash = buildXtoHash(sd, sc2);
}

sd.inv = buildInv(sd, sc2);

Expand Down
11 changes: 11 additions & 0 deletions test/runnable/cassert.d → test/runnable/betterc.d
Expand Up @@ -10,6 +10,17 @@ void test(int ij)
assert(ij,"it is not zero");
}

/*******************************************/
// https://issues.dlang.org/show_bug.cgi?id=17843

struct S
{
double d = 0.0;
int[] x;
}

/*******************************************/

extern (C) int main()
{
test(1);
Expand Down

0 comments on commit 1d2da66

Please sign in to comment.