C pre-DR#8: va_list objects

Dale Johannesen dalej@apple.com
Wed Sep 29 06:13:00 GMT 2004


> This pre-DR is for the question Jakub raised in
> <http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02802.html> of the 
> validity
> of using arrays of va_list (which cause an ICE on some platforms; bug
> 17716) and structures containing va_list.  It's clear what the 
> semantics
> should be for the use of any lvalue for an object of type va_list, and 
> as
> a quality of implementation matter we should accept uses with any such
> expression and compile them correctly without ICE, but it isn't clear
> whether they are strictly valid (though if not I think that is more 
> likely
> an oversight in the standard than a deliberate decision).

But what is an "object of type va_list"?  Consider:

struct { int x; } x;
int y[10];

x.x = 3;
y[3] = 3;

How can you justify the legality of these under the strict aliasing 
rule?
There is nothing there about references to parts of an object.  It seems
x.x and y[3] must be considered objects in their own right, however
counterintuitive that is.  This appears to be permitted under the (very
vague) definition of "object".  (Geoff suggested this interpretation,
and while I can't say I like it I think he must be right.)

> 6. Structure containing va_list.
>
>     #include <stdarg.h>
>
>     void
>     f (int a, ...)
>     {
>       struct { int a; va_list b; } aps;
>       va_start(aps.b, a);
>       // ...
>       va_end(aps.b);
>     }

So this is fine, because aps.b is an object.



More information about the Gcc mailing list