This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: strlen() and constant folding


Bryan Christ wrote:
> Is there some way to tell gcc to behave in a way that would be
> analogous to constant folding when dealing with strlen() calls where
> the target is const char* type?  If there is a macro or different
> directive that would accomplish the same, that would be okay for my
> purposes.

Works for me:

int poo(void)
{
  return strlen("test");
}

poo:
	movl	$4, %eax
	ret

Andrew.


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