This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Tiny patch] builtin_constant_p improvement.


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");
> }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]