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:
> thanks.  what about about the case i described below?

(Gods, this top-posting is confusing.)

I don't understand what you're asking.  You asked about the case, I
replied with the code gcc generates for it.  What more do you want
me to say?

Andrew.


> On Tue, Jun 30, 2009 at 11:46 AM, Andrew Haley<aph@redhat.com> wrote:
>> Bryan Christ wrote:
>>> Interesting.  Is this documented somewhere?
>> I doubt it.  Most optimizations aren't specially documented.
>>
>>> Is it reliable cross-platform?
>> Yes.
>>
>>> What if...
>>>
>>> int poo(void)
>>> {
>>>    const char *test="test";
>>>    const char *foo;
>>>
>>>    foo=test;
>>>
>>>    return strlen(foo);
>>> }
>> poo():
>>        movl    $4, %eax
>>        ret


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