Skip to content

Commit

Permalink
Merge pull request #3662 from ibuclaw/fix12900
Browse files Browse the repository at this point in the history
Only do *&ex -> ex optimisation if there is no type punning involved
  • Loading branch information
yebblies committed Jun 13, 2014
2 parents fdc6e44 + 4da4da1 commit ec3bfe0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/optimize.c
Expand Up @@ -373,12 +373,13 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue)
//printf("PtrExp::optimize(result = x%x) %s\n", result, e->toChars());
e->e1 = e->e1->optimize(result);
// Convert *&ex to ex
// But only if there is no type punning involved
if (e->e1->op == TOKaddress)
{
Expression *ex = ((AddrExp *)e->e1)->e1;
if (e->type->equals(ex->type))
ret = ex;
else
else if (ex->type->implicitConvTo(e->type) >= MATCHconst)
{
ret = ex->copy();
ret->type = e->type;
Expand Down

0 comments on commit ec3bfe0

Please sign in to comment.