__builtin_constant_p and inline assembly constraints

Miles Bader miles@gnu.org
Tue Aug 22 13:44:00 GMT 2006

Simon Kagstrom <simon.kagstrom@bth.se> writes:
> When I compile code which uses the above call (puts("Hello, cruel world!\n");,
> const char* argument), I get the following:
> I realize that GCC cannot detect all constant values with
> __builtin_constant_p(), but in this case it seems internally
> inconsistent - it apparently emits a constant for the string
> address. Any takes? Would this qualify as a bug?

I think __builtin_constant_p is supposed to return true if its argument
is constant to the _compiler_.

Is a string really a "constant" in that sense?  It's an address which
won't be known until link time, so I'd think not.  The compiler can
generate _code_ that refers the string as a constant, because the
instruction's reference to it will be fixed up at link-time, but still,
it's not a compile-time constant.

Saa, shall we dance?  (from a dance-class advertisement)

More information about the Gcc-help mailing list