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

            Bug ID: 33089
           Summary: Static value in depended class is treated as
                    non-constant expression.
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: tomasz...@gmail.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

For following code:
#include <type_traits>

template<typename U, typename T>
decltype(U{T::value}) foo(T, int) { return T::value; }

template<typename U, typename T>
U foo(T, ...) = delete;

int main()
{
    foo<short>(std::integral_constant<int, 20>{}, 0);
}

Candidate foo(T, int) is ignored with following error:
  substitution failure [with U = short, T = std::__1::integral_constant<int,
20>]: non-constant-expression cannot be narrowed from type 'int' to 'short' in
initializer list decltype(U{T::value}) foo(T, int) { return T::value; }
As suggested the T::value is not constexpr expression, despite declared as
constexpr.

If the declaration is changed to us an compile time conversion operator, the
expression is properly regonized as compile time constant, and brace
initialization is well-formed. 
template<typename U, typename T>
decltype(U{T{}}) foo(T, int) { return T::value; }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to