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

             Bug #: 14273
           Summary: sizeof... in return type causes segfault
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified


Using sizeof... in the return type of a function with variadic arguments
segfaults. See the following code example, reduced from a simple
'make_std_array' function. As you can see, if I use a template to calculate the
size of the variadic arguments, rather than sizeof..., then the code works
fine.

Broken in today's svn.


template<typename T, int i>
struct myType
{ };

template<typename T, typename... Args>
struct Counter
{
  static const int count = 1 + Counter<Args...>::count;
};

template<typename T>
struct Counter<T>
{
  static const int count = 1;
};

// This works fine.
template<typename Arg, typename... Args>
myType<Arg, Counter<Args...>::count>* make_array_with_type_with_counter(const
Args&... args)
{
    return 0;
}

// This segfaults
template<typename Arg, typename... Args>
myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args)
{
    return 0;
}


int main(void)
{
     make_array_with_type<char>(1,2,3);
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to