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

            Bug ID: 41845
           Summary: Crash when expanding an empty fold expression
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Created attachment 21932
  --> https://bugs.llvm.org/attachment.cgi?id=21932&action=edit
Crash Log

See https://godbolt.org/z/QJQ4A7.

#include <tuple>
#include <type_traits>
#include <utility>

template <typename... DstArgs>
struct ArgsPackChecker
{
  template <typename... SrcArgs>
  using EnableIf = std::enable_if_t<
    (std::is_convertible_v<SrcArgs, DstArgs> && ...)>;
};

template <typename DstArgsTuple,
          typename IndexSeq =
std::make_index_sequence<std::tuple_size_v<DstArgsTuple>>>
struct ArgsChecker;

template <typename DstArgsTuple, int... Is>
struct ArgsChecker<DstArgsTuple, std::index_sequence<Is...>>
{
  template <typename... SrcArgs>
  using EnableIf =
    typename ArgsPackChecker<std::tuple_element_t<Is,
DstArgsTuple>...>::template EnableIf<SrcArgs...>;
};

template <typename... Args,
          typename = typename ArgsChecker<std::tuple<>>::template
EnableIf<Args...>>
void f(Args&&... args)
{
}

This builds without an error with GCC 9.1, but crashes with clang trunk. The
attached crash backtrace was generated using Xcode 10.2.1 using the following
command:

$ clang -std=c++17 test.cpp
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://developer.apple.com/bugreporter/ and include the crash backtrace,
preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg:
/var/folders/v1/0ffrrhw11394l1p_rl193z340000gn/T/test-87fcfd.cpp
clang: note: diagnostic msg:
/var/folders/v1/0ffrrhw11394l1p_rl193z340000gn/T/test-87fcfd.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg:
/Users/ryan/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your
crash)
clang: note: diagnostic msg: 

********************

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to