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: Semantics of MODIFY_EXPR with CONSTRUCTOR rhs


| On Sun, Aug 01, 2004 at 11:20:06PM -0400, Richard Kenner wrote:
| > Suppose we have this in .t03.original:
| > 
| >   r = {.x=5, .y=8};
| >   r = {.x=1, .y=r.x};
| > 
| > Is the second statement valid?

The second statement is valid.  The syntactic and grammatical validity
is no valid different from the situation 

   struct S {
      void* data;
   };

   strust S s = { &s.data };

| ...
| > What's supposed to be happening here?

My understanding is that it is a behvaiour unspecified by the C99
standard, 6.7.8 Initialization:

       [#23] The order in which any side effects  occur  among  the
       initialization list expressions is unspecified.130)

Footnote 130 says:

       130In  particular, the evaluation order need not be the same
          as the order of subobject initialization.


I would suggest we warn user, and let optimizer decides ;-)

-- Gaby


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