This is the mail archive of the gcc-patches@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++] RFC: partial C99 designated-initializers support


Bernardo Innocenti wrote:

Richard Henderson wrote:

On Fri, Oct 22, 2004 at 11:47:49PM +0200, Bernardo Innocenti wrote:

Bootstrapped and not tested as this will have to wait for
4.1 anyway.



It definitely doesn't work. I'd written all of the parsing bits once, until I stumbled upon the fact that the front end doesn't even support the gnu extension properly -- it doesn't support having the fields specified out of order. Which is basically the whole point.


Out-of-order initializers are checked for in process_init_constructor(),
with a sorry("non-trivial labeled initializers").  Would that be easy
to fix?  And would it be welcome?

What does C99 say should happen in this case:


int i[] = { [3] = 7, [2] = i[3] };

? In C++, it would be wrong to actually initialize the elements of an array/structure in anything other than the order in which they are declared, as otherwise the destructors for elements would not be run in the reverse order of construction. So, I'm concerned about the possibility that the same code might not mean the same thing in C and in C++.

Aside from that concern, I think it's a matter of only moderately much work to make labeled initializers work in C++. I think it would be welcome, despite the fact that is not part of ISO C++, because, generally, we're trying to support C99 in C++. Other C++ maintainers might have other opinions, though.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


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