[LLVMbugs] [Bug 21103] New: clang does not correctly compile constexpr function for literal types that have a non-constexpr copy constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Sep 30 14:53:36 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21103

            Bug ID: 21103
           Summary: clang does not correctly compile constexpr function
                    for literal types that have a non-constexpr copy
                    constructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ryan.burn at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

clang gives an error when compiling the code below.

But this should be valid c++ code, since B<-1> is a literal_type and the
requirements for f being a constexpr function call should be met. (also it
compiles with g++)

#include <array>
#include <type_traits>
#include <iostream>

template<class T, int N> 
class A {
 public:
  T values[N];
 public:
  constexpr A() : values{} {} 
  A(const A&) {} 
  A(int x) {} 
};

template<int... Extents>
class B  
  : A<int, 10>
{
};

template<class T> 
constexpr int f(T) {
  return 0; 
}

int main() {
  std::array<int, f(B<-1>())> a; 
  // std::cout << std::is_literal_type<B<-1>>::value << "\n";   prints true
  return 0; 
}

-- 
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/20140930/274c55fd/attachment.html>


More information about the llvm-bugs mailing list