[cfe-dev] On which option should vector operator ? : depend?
Sebastian Redl
sebastian.redl at getdesigned.at
Wed Sep 29 10:41:02 PDT 2010
On Sep 29, 2010, at 10:06 AM, Daniel Dunbar wrote:
> On Mon, Sep 27, 2010 at 11:03 AM, Douglas Gregor <dgregor at apple.com> wrote:
>>
>> I think it's perfectly reasonable for ? : to work on vectors, even if neither Altivec nor OpenCL are enabled.
>
> I'm not sure I agree. What are the semantics?
>
> In my opinion, the right semantics for ?: for vectors, relative to the
> C language, is that (cond ? LHS : RHS <=> (cond == 0) ? LHS : RHS. But
> that isn't a very useful operation on vectors, and may be surprising
> to some users. I can see an argument for implementing it just for
> orthogonality.
>
> Having ?: mean a vector select seems wrong to me.
It seems weird to me too, but I think the question here is not whether to have it - IIUC OpenCL demands it - but whether it makes sense to make it work conditionally only for some language flags. And IMO, if you have ?: mean vector select in one dialect, you might as well make it work in all of them.
Sebastian
More information about the cfe-dev
mailing list