Hello!
There was a similar question to this on the mailing list archives, but
I could not
find the answer.
I would like to combine __builtin_choose_expr with __builtin_constant_p, in
something like this:
#define SHIFTLEFT(a,b) __builtin_choose_expr(__builtin_constant_p(b), \
((a) << (b)), \
((a) << (MIN(31,MAX(-31,(b)))))
I could use this to determine whether I need special behavoir, because I might
be able to assume that constants were never in some "bad range" of values.
Unfortunately, when I try this, I get:
file.c:42 error: first argument to __builtin_choose_expr not a constant
However, according to the documentation, __builtin_constant_p should
return 0 if the compiler cannot prove that the argument expression
is a constant. One would expect that 0 is a constant, and that it should
always be a valid first argument to __builtin_choose_expr.
Am I doing something wrong? Perhaps we could have
__builtin_constant_constant_p() that would be a valid constant always?
Thanks!
Erich
--
Why are ``tolerant'' people so intolerant of intolerant people?