FS#47348 - clang++ segfault with variadic templates, lambdas and std::forward (after ABI change)

Attached to Project: Arch Linux
Opened by Vittorio Romeo (vittorioromeo) - Saturday, 12 December 2015, 15:25 GMT
Last edited by Doug Newgard (Scimmia) - Saturday, 12 December 2015, 15:48 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

After the ABI update, clang++ segfaults while trying to compile the following C++14 code snippet.
(Note that the segfault didn't happen before the ABI update, and that it doesn't happen on gcc.godbolt.org: https://goo.gl/WrdeqF)



#include <utility>

template <typename... Ts>
constexpr decltype(auto) outer_wrapper(Ts&&...)
{
return int{};
}

struct static_for_result
{
template <typename T>
constexpr decltype(auto) get_fn_wrapper(T) noexcept
{
return [this](auto&&...)
{
};
}

template <typename T, typename... Ts>
constexpr decltype(auto) inner_wrapper(T, Ts&&...)
{
return outer_wrapper(get_fn_wrapper(T{}));
}

template <typename... Ts>
constexpr decltype(auto) operator()(Ts&&... xs)
{
auto fn_call = [this, &xs...]()
{
return inner_wrapper(int{});
};

return int{};
}
};

template <typename TF>
constexpr decltype(auto) static_for(TF&&)
{
return static_for_result{};
}

int main()
{
return static_for([](auto, auto)
{
})(0);
}




clang++ output:

clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.2.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/5.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/5.3.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/usr/bin/clang-3.7" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name rip_abi.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -g -dwarf-column-info -resource-dir /usr/bin/../lib/clang/3.7.0 -internal-isystem /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0 -internal-isystem /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/x86_64-unknown-linux-gnu -internal-isystem /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.7.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -Wpedantic -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /media/veeData/Temp -ferror-limit 19 -fmessage-length 100 -fsanitize=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr -fsanitize-recover=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/rip_abi-281042.o -x c++ ./rip_abi.cpp
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/x86_64-unknown-linux-gnu
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/backward
/usr/local/include
/usr/bin/../lib/clang/3.7.0/include
/usr/include
End of search list.
clang-3.7: error: unable to execute command: Segmentation fault (core dumped)
clang-3.7: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang-3.7: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-3.7: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.7: note: diagnostic msg: /tmp/rip_abi-f501e4.cpp
clang-3.7: note: diagnostic msg: /tmp/rip_abi-f501e4.sh
clang-3.7: note: diagnostic msg:

********************
This task depends upon

Closed by  Doug Newgard (Scimmia)
Saturday, 12 December 2015, 15:48 GMT
Reason for closing:  Duplicate
Additional comments about closing:   FS#47329 

Loading...