This is the mail archive of the gcc@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: C pre-DR#8: va_list objects


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.



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