This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Tiny patch] builtin_constant_p improvement.
- To: Ralph Loader <suckfish at ihug dot co dot nz>
- Subject: Re: [Tiny patch] builtin_constant_p improvement.
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Date: Fri, 4 Aug 2000 15:13:02 +0200
- Cc: gcc at gcc dot gnu dot org
- References: <14729.54163.779907.515622@sucky.fish>
Just as well, because Glibc assumes this does work. See strlen,
<bits/string2.h>.
-- Jamie
Ralph Loader wrote:
> The enclosed patch causes the following (recently posted) code to
> return 1 when compiled as C code. (It already does when compiled as
> C++). It removes an assumption that pointers can only be constant if
> they are literals.
>
> inline int f (const char *const s)
> {
> if (__builtin_constant_p (s))
> return 1;
> else
> return 0;
> }
>
> int g ()
> {
> return f ("abc");
> }