This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Don't accept e.g. "(int *)(long)&x" as a constant expression if x is in address space != 0.
Needs ReviewPublic

Authored by mjacob on Dec 7 2015, 5:13 PM.

Details

Reviewers
rsmith
Summary

The constant expression evaluator for pointers returns a base and an
offset if successful. In this case, CodeGen generates a constant pointer cast,
casting the base (with offset applied if necessary) to the destination type.
However, that is different from casting the base to an integer and then to the
destination type if the destination points to another address space as the
base. Supporting this would require a lot of work because it can't be
expressed as base + offset. Changing the whole constant expression evaluator
is not worthline for supporting this special case.

Diff Detail

Event Timeline

mjacob updated this revision to Diff 42129.Dec 7 2015, 5:13 PM
mjacob retitled this revision from to [Sema] Don't accept e.g. "(int *)(long)&x" as a constant expression if x is in address space != 0..
mjacob updated this object.
mjacob added a reviewer: rsmith.
mjacob added subscribers: cfe-commits, alex.