[cfe-dev] Incongruency in __builtin_constant_p with pointer argument

Joerg Sonnenberger joerg at britannica.bec.de
Thu Apr 28 01:26:34 PDT 2011


On Thu, Apr 28, 2011 at 07:55:34AM +0200, Abramo Bagnara wrote:
> I think that clang is right to consider pointer to static memory region
> to be constant at compile-time and hence candidate to constant-folding.
> (note that the documentation does not say "constant with a known value
> at compile-time", but "value known to be constant at compile time").

Pointers are only semi-constant. You can consider them as constants for
a few purposes (e.g. adding or substracting them), but anything else
generally doesn't work due to the limitations of the relocation model.
As such, it doesn't make sense to me to return True since they can't be
fully used with constant-folding.

Joerg



More information about the cfe-dev mailing list