← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH 1/2] Last argument before ellipsis may not be reference

 

On Sun, Sep 13, 2015 at 02:49:21PM +0200, Simon Richter wrote:

> The C++ specification disallows this to permit implementations that use
> the address-of operator and sizeof to calculate the address of the first
> argument inside the ellipsis; sizeof(foo &) gives the size of the "foo"
> class rather than the space taken up by the reference.

Pretty obscure rule, never heard of that :D I know that the 'thing' in
the vararg are pretty limited (IIRC only ints, doubles and pointers) but
never heard of a limitation in the address before. Well, it's C++ only,
C doesn't suffer from that problem:P

I suppose that is talking about the implementation of va_start: address
of last+sizeof of last gives the starting point of the va_list (in the
'correct' stack direction, obviously); am I correct?

Otherwise there should be 'compiler magic' involved in the va_*
implementation (it knows that a reference is passed by address). gcc
probably seems to be using this magic:
https://gcc.gnu.org/onlinedocs/gccint/Varargs.html

... let me guess, a clang warning?

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups

References