[LLVMbugs] [Bug 14273] New: sizeof... in return type causes segfault

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 6 08:23:57 PST 2012


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: unassignedclangbugs at nondot.org
        ReportedBy: chris at bubblescope.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.



More information about the llvm-bugs mailing list