220 7744 <5347204.PXDO8jBI6L@tjmaciei-mobl2> article
Path: news.gmane.org!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal to add C99 designated initializers to C++
Date: Wed, 13 Nov 2013 14:53:11 -0800
Lines: 66
Approved: news@gmane.org
Message-ID: <5347204.PXDO8jBI6L@tjmaciei-mobl2>
References: <a54ba091-3aeb-4fd5-b55e-584571f4e746@isocpp.org> <60181971.rjyeC72bSi@tjmaciei-mobl2> <CAOfiQqkGoGwUJ8pZSu8UEB2BZHAZuFHL2A4D0L32NB=JbqF+mA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1384383196 929 80.91.229.3 (13 Nov 2013 22:53:16 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 13 Nov 2013 22:53:16 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBXEFSCKAKGQESNBC7YQ@isocpp.org Wed Nov 13 23:53:21 2013
Return-path: <std-proposals+bncBCB4TK757YBRBXEFSCKAKGQESNBC7YQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ea0-f199.google.com ([209.85.215.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCB4TK757YBRBXEFSCKAKGQESNBC7YQ@isocpp.org>)
	id 1VgjJG-0004GK-0E
	for gclcip-std-proposals@m.gmane.org; Wed, 13 Nov 2013 23:53:18 +0100
Original-Received: by mail-ea0-f199.google.com with SMTP id f15sf1312905eak.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 13 Nov 2013 14:53:17 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:date:message-id:user-agent
         :in-reply-to:references:mime-version:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-transfer-encoding:content-type;
        bh=QvOPc1V6xbSU4GKlTtZzZK1nVSzVCYnwzTm8LqA4ZlY=;
        b=PvKYcNs29lINBBa7fkXcZfGLaQ9wnIzfzvZoTVg62sdajn4HclFFpX+oYEDV+D+PJG
         OnkvnjH8buKXFNoV/HCIuLG+WbF8fGlXCaAdFm+Nk57EYMHSA3Fg/amrNf1iensjlAjb
         jW95JNyj2ufB1FEOctGJFXoMnhCmZUT9wT30KD8AosOf2xLDeWLeZOrl35QWSiGJf+x6
         cBCTqHZ6/UTtaeYCbRvUY0tLB8cPgtH10l8IPjTD1++W0RQUyIHXgtg1m+Ro5D39MNG+
         abbHq+o3pHdpfNMtgxSCo1pDO7BYUCsDsCgC2+CqkHBeDPaoBuls37w5XhbHYVlrTY6M
         8B0 
X-Gm-Message-State: ALoCoQmC5u5Am6u7KKyOdpdfLpMzapg2W2xuqbm4L2Wploveucwkc2iXTeW+CFvPHO+YjoT3fLO3
X-Received: by 10.205.19.4 with SMTP id qi4mr37959bkb.1.1384383197444;
        Wed, 13 Nov 2013 14:53:17 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.211.49 with SMTP id mz17ls1120621wic.13.canary; Wed, 13
 Nov 2013 14:53:16 -0800 (PST)
X-Received: by 10.14.42.6 with SMTP id i6mr5043534eeb.65.1384383196260;
        Wed, 13 Nov 2013 14:53:16 -0800 (PST)
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
        by mx.google.com with ESMTP id j41si71288eeg.158.2013.11.13.14.53.16
        for <std-proposals@isocpp.org>;
        Wed, 13 Nov 2013 14:53:16 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) client-ip=2a01:4f8:d13:f81:21c:14ff:fe01:12a3;
Original-Received: from tjmaciei-mobl2.localnet (unknown [IPv6:2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
	by gondolin.macieira.info (Postfix) with ESMTPSA id 97A9012C01B
	for <std-proposals@isocpp.org>; Wed, 13 Nov 2013 14:53:15 -0800 (PST)
User-Agent: KMail/4.12 pre (Linux/3.9.10-100+i915fix.fc17.x86_64; KDE/4.11.60; x86_64; git-8054221; 2013-08-01)
In-Reply-To: <CAOfiQqkGoGwUJ8pZSu8UEB2BZHAZuFHL2A4D0L32NB=JbqF+mA@mail.gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3
 as permitted sender) smtp.mail=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:7744
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/7744>

On ter=E7a-feira, 12 de novembro de 2013 17:36:03, Richard Smith wrote:
> > Shouldn't compilers emit then a diagnostic if you fail to sequence them=
 in
> > the
> > right order?
>=20
> Sure, they can, just as they do for constructor initializers. And, just a=
s
> with constructor initializers, we need to sequence the subobject
> initialization in subobject order, in order to get destructors to run in
> the right order.

Good.

>=20
> > struct S {
> >=20
> >     int a, b;
> >=20
> > };
> >=20
> > int i;
> > int f(int *i) { *i =3D 42; return 47; }
> >=20
> > struct S g()
> > {
> >=20
> >     struct S s =3D { .b =3D f(i), .a =3D i };
>=20
> I assume you meant f(&i) here?

Yes. I had a reference first, then I changed to a pointer so I could compil=
e in=20
C mode...

>     return s;
>=20
> > }
> >=20
> > When compiled as C99, the above returns { .a =3D 42, .b =3D 47 }.
>=20
> Only by chance. C99 6.7.8/23 says: "The order in which any side effects
> occur among the initialization list expressions is unspecified."

Ah, ok. So my code actually has undefined behaviour. For C++, though, we do=
=20
have an order and we also have to initialise sub-objects in the correct ord=
er.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.
