<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Segfault with variadic templates, lambdas and std::forward (after gcc ABI change)"
   href="https://llvm.org/bugs/show_bug.cgi?id=25814">25814</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault with variadic templates, lambdas and std::forward (after gcc ABI change)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++14
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vittorio.romeo@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15434" name="attach_15434" title="Preprocessed files and associated run scripts">attachment 15434</a> <a href="attachment.cgi?id=15434&action=edit" title="Preprocessed files and associated run scripts">[details]</a></span>
Preprocessed files and associated run scripts

After the "Arch Linux 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: <a href="https://goo.gl/WrdeqF">https://goo.gl/WrdeqF</a>)

I've reported the bug on Arch's tracker as well.



#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
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> 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:</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>