[cfe-commits] [PATCH] Add extension to allow initializer list to initialize complex numbers by component

Douglas Gregor dgregor at apple.com
Fri Sep 16 21:19:02 PDT 2011


On Sep 16, 2011, at 5:48 PM, Eli Friedman wrote:

> Patch attached.  Simple example this patch allows:
> 
> _Complex float x = { 1.0f, INFINITY }; // Init to (1, Inf)
> 
> This construct is useful in that currently with clang, there is no way
> to correctly represent this construct in static initializers, and
> representing it for non-static variables using __imag__ is messy.
> According to Doug, gcc also will be implementing this extension, and
> it seems like an obvious extension in the sense that there is no other
> meaning which could reasonably be assigned to this construct.
> 
> Note that this extension does not allow eliding the braces; the
> meaning of the following two lines is different:
> 
> _Complex float x[] = { { 1.0f, 1.0f } }; // [0] = (1, 1)
> _Complex float x[] = { 1.0f, 1.0f }; // [0] = (1, 0), [1] = (1, 0)
> 
> 
> Please comment if anyone sees any issues with this extension.
> (Comments also welcome on the patch.)

This looks great, Eli. Thanks!

	- Doug



More information about the cfe-commits mailing list