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: www.gnu.org/software/gcc/bugs/#nonbugs_c (with ++ / --)


On 4 July 2014 08:33, Fabian Cenedese wrote:
>
>>> Nothing defined
>>> implementation of the passage of a function settings. But it turns out that
>>> in the case of gcc, they are pushed onto the stack from right to left.
>>
>>I think it depends on the hardware architecture.
>>
>>> As it
>>> has been since the dawn of time in Savannah, it is definitely impossible to
>>> change this state of affairs in gnou. Thus be it!
>>>
>>>     So my question is: reverse the order of parameters (shock me, but) make
>>> functional! What about you? Portability?
>>
>>I don't understand the question.
>
> He probably means that if he reverses the argument order (like a+=1, b, a) then
> he'd get the desired result. But as you mentioned it probably depends on the
> hardware and compiler so it is not portable.
>
> I'd say this is undefined behaviour and could be solved like
> c=a;
> foo(c, b, a+=1);        // order of evaluation not important

Agreed, that is a safe and portable way to do it.


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