This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
__builtin_constant_p not evalutating to a constant
- From: Erich Plondke <eplondke at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 14 Jan 2005 11:27:19 -0600
- Subject: __builtin_constant_p not evalutating to a constant
- Reply-to: erich at wreck dot org
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
(sent to gcc-bugs, but then realized it was probably a problem between
chair and keyboard, so sending to gcc-help)
--
Why are ``tolerant'' people so intolerant of intolerant people?