Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Merge fix for Bug #24 from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jun 13, 2014
1 parent d4ec1b0 commit 91835c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gcc/d/dfrontend/optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,23 @@ Expression *PtrExp::optimize(int result, bool keepLvalue)
//printf("PtrExp::optimize(result = x%x) %s\n", result, toChars());
e1 = e1->optimize(result);
// Convert *&ex to ex
// But only if there is no type punning involved
if (e1->op == TOKaddress)
{ Expression *e;
Expression *ex;

ex = ((AddrExp *)e1)->e1;
if (type->equals(ex->type))
e = ex;
else
else if (ex->type->implicitConvTo(type) >= MATCHconst)
{
e = ex->copy();
e->type = type;
}
else
{
return this;
}
return e;
}
if (keepLvalue)
Expand Down
17 changes: 17 additions & 0 deletions gcc/testsuite/gdc.test/runnable/gdc.d
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ void test19()

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

// Bug 24

void test24()
{
struct S24
{
char[1] b;
}

S24 a;

if (*a.b.ptr)
return;
}

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

// Bug 29

void test29()
Expand Down

0 comments on commit 91835c9

Please sign in to comment.