[cfe-dev] [RFC] Disabling part of -flax-vector-conversions by default (PR17164)

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Wed May 8 20:56:26 PDT 2019


On Wed, 10 Apr 2019 at 14:32, Richard Smith <richard at metafoo.co.uk> wrote:
> Hi all,
>
> As noted in PR17164, -flax-vector-conversions is enabled by default in
> Clang. This permits a bunch of unsafe and deeply surprising implicit
> conversions in two categories:
>
> Category 1:
>   a vector of integer type can be implicitly converted to a vector of
> different integer type (with a potentially different number of
> elements) so long as the bit width is equal; this is performed as a
> bit-cast (eg, vector of 4 ints implicitly converts to a vector of 16
> chars)
>
> Category 2:
>   a vector of floating-point type can be implicitly converted to/from
> a vector of integer or different floating point type (with a
> potentially different number of elements) so long as the bit width is
> equal; this too is performed as a bit-cast (eg, vector of 4 floats
> implicitly converts to vector of 4 ints, and the conversion is a
> bit-cast)
>
> PR17164 notes that all compilers other than Clang permit category 1
> but not category 2, particularly when using the Intel __m128 (etc)
> typedefs.
>
> Proposal: add new flags:
>
> -flax-vector-conversions=none: disable category 1 and category 2 (same
> as old -fno-lax-vector-conversions)
> -flax-vector-conversions=integer: disable category 2 only (NEW)
> -flax-vector-conversions=all: enable both categories (same as old
> -flax-vector-conversions)
>
> ... and make -flax-vector-conversions=integer the default.
>
> Any comments or objections?

No objections raised in a month; I'm going to go ahead with this.



More information about the cfe-dev mailing list