[cfe-dev] Incongruency in __builtin_constant_p with pointer argument

Miles Bader miles at gnu.org
Thu Apr 28 01:48:23 PDT 2011


Abramo Bagnara <abramo.bagnara at gmail.com>
writes:
> 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").

Whatever wording is in the documentation, I think people tend to _use_
__builtin_constant_p as if it means "the value is known to the
compiler/optimizer, and so most of the calculation can be done at
compile-time."  A "constant" known only at link-time would break this
assumption.

So if consistency is necessary (I dunno), it seems better to follow gcc
and declare them both non-__builtin_constant_p.

-Miles

-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff




More information about the cfe-dev mailing list