Accessing non-existing varargs argument

Richard Earnshaw rearnsha@arm.com
Mon Dec 15 11:55:00 GMT 2014


On 15/12/14 11:44, Florian Weimer wrote:
> On 12/15/2014 12:39 PM, Richard Earnshaw wrote:
>> On 12/12/14 23:50, Florian Weimer wrote:
>>> On 12/12/2014 08:02 PM, Jeff Law wrote:
>>>
>>>> It'd probably work for the specific cases Florian wants to tackle, but
>>>> I'd consider it highly non-portable.
>>>
>>> I agree, that's why I asked for something “GCC-portable”.
>>>
>>
>> Don't go this way.  Seriously, you can't assume that a future platform
>> ABI won't break if you do.  ABI's at this level really aren't controlled
>> by GCC, which just has to conform to whatever the platform ABI requires.
>>   We were very close in AArch64 to defining the ABI for variadics to push
>> all variadic (from the ... onwards) arguments onto the stack - it leads
>> to a very simple ABI from an implementation viewpoint and eliminates
>> much of the grotty code around reconstructing the parameter list.
> 
> This would still work except in a very pathological corner case which 
> cannot happen with glibc (the stack cannot be empty when the open 
> function is called because all user code runs with a non-empty stack).
> 
> Did you shy away from the simple implementation because of too many 
> interop failures?
> 

We certainly ran into some problems with non-conforming code.  Not least
of which was GCC itself :-( - though I think that particular issue has
been fixed now.  It certainly created enough uncertainty as to the depth
of the rabbit hole that we decided not to pursue that avenue.

R.



More information about the Gcc-help mailing list