[cfe-dev] Issues with vector initialization using parentheses

Eli Friedman eli.friedman at gmail.com
Thu Aug 30 19:29:35 PDT 2012


On Thu, Aug 30, 2012 at 7:12 PM, Magee, Josh <Joshua.Magee at am.sony.com> wrote:
> Hi,
>
> I noticed some issues with vector initialization using parentheses.
>
> Consulting the Clang documentation: http://clang.llvm.org/docs/LanguageExtensions.html#vectors
> See the following paragraph on Vector Literals:
> "Vector literals can be used to create vectors from a set of scalars, or
> vectors. Either parentheses or braces form can be used. In the parentheses form
> the number of literal values specified must be one, i.e. referring to a scalar
> value, or must match the size of the vector type being created. If a single
> scalar literal value is specified, the scalar literal value will be replicated
> to all the components of the vector type. In the brackets form any number of
> literals can be specified."

The docs here are incomplete; parentheses only work when either
AltiVec or OpenCL is enabled.  Otherwise, you're just getting plain C
semantics for commas.

-Eli



More information about the cfe-dev mailing list