[cfe-dev] Allow constexpr in vector extensions

Halfdan Ingvarsson via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 29 12:11:53 PDT 2017


The original snippet compiles fine. The problem occurs when you try to
constexpr the 'c' variable:


typedef int v4si __attribute__ ((vector_size (16)));

int main()
{
    constexpr v4si a = {1,2,3,4};
    constexpr v4si b = {2,0,0,0};
    constexpr v4si c = a + b;
}
-----
Output:

constexpr v4si c = a + b;
                     ~
error: constexpr variable 'c' must be initialized by a constant expression
-----

https://godbolt.org/g/KYBmsB

- ½

On 29 August 2017 at 14:36, Jeff Hammond via cfe-dev <cfe-dev at lists.llvm.org
> wrote:

> I see no errors with Clang 3.8, 3.9, 4.0 and GCC 5, 6, 7 on my Haswell
> Mac.  Try setting -std= appropriately, given that constexpr is a C++11
> feature.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170829/6eb4b7e5/attachment.html>


More information about the cfe-dev mailing list