C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Designated initializers in C++ and C

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Thu, 13 Aug 2020 13:15:20 +0200

on Thu, 13 Aug 2020 12:30:59 +0200 you (Florian Weimer
<fw_at_[hidden]>) wrote:

> * Jens Gustedt:

> > So here, a general recommendation would then also be for
> > implementations to use the order as specified.
> Yes, this is a good point. But it raises the question how C++
> programmers can know whether it is portable to use a designated
> initializer with a type from a standard header.

This is not limited to designated initializers. They basically can't
write an initializer with non-trivial values that would be guaranteed
to be portable.

In block scope, people could (and do) fall back to assignment of the
individual members, but with the possible pitfall that they forget to
initialize the stucture as a whole and so uninitialized members would

For file scope, which is the main target for C/C++ compatibility, the
only possibility to cope with that is `#ifdef` guessing.

Over all, these are severe restrictions of the usability of the
designated initializer concept as it was intended for C.


:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2020-08-13 06:18:48