On 25/04/12 12:09, Jakub Jelinek wrote:
> On Wed, Apr 25, 2012 at 11:57:09AM +0200, Richard Guenther wrote:
>> void *foo ()
>> {
>>   return __builtin_return_address (0);
>> }
>>
>> void *bar (_Bool b)
>> {
>>   if (b)
>>     return foo ();
>>   else
>>     return foo ();
>> }
>>
>> int main()
>> {
>>   if (bar(true) == bar(false))
>>     abort ();
>> }
>>
>> ok ... outside of the scope of standard "C", but we certainly _can_ do this.
>> Which would question tail-merging the above at all, of course.
> 
> I don't think we guarantee the above, after all, even pure functions may
> use __builtin_return_address (0) - it doesn't modify memory, and we happily
> remove pure calls, CSE the return values etc.
> 

Jakub,

pure:
- no effects except the return value
- return value depends only on the parameters and/or global variables

AFAIU, given this definition, a pure function cannot use
__builtin_return_address since it would mean that the return value depends on
something else than parameters and global variables.

Thanks,
- Tom

>       Jakub

Reply via email to