Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 13831 - DMD crash on newing struct with overlapped fields in CTFE #4205

Merged
merged 1 commit into from
Dec 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ctfeexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,8 @@ void assignInPlace(Expression *dest, Expression *src)
assert(o->op == e->op);
assignInPlace(o, e);
}
else if (e->type->ty == Tsarray && o->type->ty == Tsarray && e->op != TOKvoid)
else if (e->type->ty == Tsarray && e->op != TOKvoid &&
o->type->ty == Tsarray)
{
assignInPlace(o, e);
}
Expand Down
5 changes: 4 additions & 1 deletion src/interpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ class Interpreter : public Visitor
void visit(StructLiteralExp *e)
{
#if LOG
printf("%s StructLiteralExp::interpret() %s\n", e->loc.toChars(), e->toChars());
printf("%s StructLiteralExp::interpret() %s ownedByCtfe = %d\n", e->loc.toChars(), e->toChars(), e->ownedByCtfe);
#endif
if (e->ownedByCtfe)
{
Expand Down Expand Up @@ -2943,6 +2943,9 @@ class Interpreter : public Visitor
if (e->member)
{
Expression *se = e->newtype->defaultInitLiteral(e->loc);
se = interpret(se, istate);
if (exceptionOrCant(se))
return;
result = interpret(e->member, istate, e->arguments, se);
}
else
Expand Down
29 changes: 29 additions & 0 deletions test/compilable/interpret3.d
Original file line number Diff line number Diff line change
Expand Up @@ -5982,6 +5982,35 @@ struct S10937
enum test10937 = S10937(7);
enum west10937 = S10937(2);

/**************************************************
13831
**************************************************/

struct Vector13831()
{
}

struct Coord13831
{
union
{
struct { short x; }
Vector13831!() vector;
}
}

struct Chunk13831
{
this(Coord13831)
{
coord = coord;
}

Coord13831 coord;

static const Chunk13831* unknownChunk = new Chunk13831(Coord13831());
}

/**************************************************
7732
**************************************************/
Expand Down