[llvm-bugs] [Bug 25704] New: Specialization differs from the template declaration with respect to the constexpr specifier

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 2 00:11:42 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25704

            Bug ID: 25704
           Summary: Specialization differs from the template declaration
                    with respect to the constexpr specifier
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tom.smart.bishop at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

In the following sample the specialization for the constructor vec<float,
__m128> differs from the template declaration vec<T, STORE> with respect to the
constexpr specifier.

#include "xmmintrin.h"

template<typename T, typename STORE>
struct alignas(16) vec {
    union {
        STORE st;
        struct { T x; T y; T z; T w; };
    };

    inline explicit constexpr vec() noexcept :
        x{0}, y{0}, z{0}, w{0} {
    }
};

template<>
inline vec<float, __m128>::vec() noexcept :
    st{_mm_setzero_ps()} {
}

When reading the standard (not sure if this is the correct source though)
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf there is a
note in "7.1.5 The constexpr specifier" that says:

[ Note: An explicit specialization can differ from the template declaration
with respect to the constexpr specifier. — end note ]

However in clang 3.7 I get the following error "non-constexpr declaration of
'vec' follows constexpr declaration" with the sample code.

(gcc 5.1 compiles)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151202/fe024a22/attachment-0001.html>


More information about the llvm-bugs mailing list