This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add __builtin_complex to construct complex values (C1X CMPLX* macros)
On Fri, 19 Aug 2011, Gabriel Dos Reis wrote:
> On Fri, Aug 19, 2011 at 10:55 AM, Joseph S. Myers
> <joseph@codesourcery.com> wrote:
> > ?Note that if you did
> > allow such initializers for C, it wouldn't provide *expressions*
> > usable in static initializers, since to make a braced initializer into
> > an expression you need a compound literal and compound literals can't
> > be used in static initializers.)
>
> Thanks for the rationale. I was puzzled until I read that bits.
> I would have thought that the natural thing to do was to fix
> C's compound literals so that they can be used in static initializers.
> Do you know why WG14 did not want to do that?
A compound literal is essentially an anonymous variable with a given
initializer, so I suppose it comes down to C not allowing const variables
(to which const qualified compound literals are equivalent, except that
they may share storage, like string constants and unlike named variables)
in initializers and I don't know a specific rationale for that difference
between C and C++.
--
Joseph S. Myers
joseph@codesourcery.com