This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Semantics of MODIFY_EXPR with CONSTRUCTOR rhs
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, gcc at gcc dot gnu dot org
- Date: 02 Aug 2004 10:15:02 +0200
- Subject: Re: Semantics of MODIFY_EXPR with CONSTRUCTOR rhs
- Organization: Integrable Solutions
- References: <10408020320.AA28900@vlsi1.ultra.nyu.edu><20040802071817.GA32236@redhat.com>
| 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