<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 --- - clang++ crashes while compiling c++14"
   href="https://llvm.org/bugs/show_bug.cgi?id=28865">28865</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang++ crashes while compiling c++14
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.8
          </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>release blocker
          </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>baluks@gmail.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=16887" name="attach_16887" title="preprocessed source">attachment 16887</a> <a href="attachment.cgi?id=16887&action=edit" title="preprocessed source">[details]</a></span>
preprocessed source

0  libLLVM-3.8.so 0x00007f9df34267d8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  libLLVM-3.8.so 0x00007f9df34243c6 llvm::sys::RunSignalHandlers() + 54
2  libLLVM-3.8.so 0x00007f9df34245aa
3  libc.so.6      0x00007f9df252c310
4  clang-3.8      0x000000000147e80c
5  clang-3.8      0x0000000001486165
6  clang-3.8      0x0000000001488d16
clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind,
long, llvm::StringRef, llvm::StringRef,
llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long> >,
llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) + 758
7  clang-3.8      0x00000000006af6d9 clang::Diagnostic::FormatDiagnostic(char
const*, char const*, llvm::SmallVectorImpl<char>&) const + 3481
8  clang-3.8      0x0000000000a0255e
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&) + 94
9  clang-3.8      0x00000000006b73a0
clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&,
clang::DiagnosticIDs::Level) const + 64
10 clang-3.8      0x00000000006b76c2
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const + 258
11 clang-3.8      0x00000000006ae4a4
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) + 84
12 clang-3.8      0x0000000000d2731a
clang::Sema::EmitCurrentDiagnostic(unsigned int) + 1450
13 clang-3.8      0x0000000000f569eb
14 clang-3.8      0x0000000000f68361
clang::InitializationSequence::Diagnose(clang::Sema&, clang::InitializedEntity
const&, clang::InitializationKind const&, llvm::ArrayRef<clang::Expr*>) + 5345
15 clang-3.8      0x0000000000f6b48d
clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity
const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>,
clang::QualType*) + 8125
16 clang-3.8      0x0000000000f6dcc7
clang::Sema::PerformCopyInitialization(clang::InitializedEntity const&,
clang::SourceLocation, clang::ActionResult<clang::Expr*, true>, bool, bool) +
199
17 clang-3.8      0x0000000001023f50
clang::Sema::PerformMoveOrCopyInitialization(clang::InitializedEntity const&,
clang::VarDecl const*, clang::QualType, clang::Expr*, bool) + 528
18 clang-3.8      0x000000000103f15c
clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*) + 1580
19 clang-3.8      0x00000000010c48fe
20 clang-3.8      0x00000000010d02c5
21 clang-3.8      0x00000000010d1fac
22 clang-3.8      0x00000000010d0545
23 clang-3.8      0x00000000010d173b
24 clang-3.8      0x00000000010d186b
25 clang-3.8      0x00000000010d05c5
26 clang-3.8      0x00000000010d430f clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&) + 95
27 clang-3.8      0x00000000010ef66a
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 3834
28 clang-3.8      0x00000000010ef939
clang::Sema::PerformPendingInstantiations(bool) + 217
29 clang-3.8      0x0000000000d2aab2 clang::Sema::ActOnEndOfTranslationUnit() +
354
30 clang-3.8      0x0000000000b97451
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 625
31 clang-3.8      0x0000000000b8a993 clang::ParseAST(clang::Sema&, bool, bool)
+ 611
32 clang-3.8      0x00000000009c2a2e clang::FrontendAction::Execute() + 302
33 clang-3.8      0x00000000009968a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 278
34 clang-3.8      0x0000000000a41c33
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2339
35 clang-3.8      0x00000000006a7918 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) + 2456
36 clang-3.8      0x00000000006a3b38 main + 5832
37 libc.so.6      0x00007f9df2519741 __libc_start_main + 241
38 clang-3.8      0x00000000006a5889 _start + 41
Stack dump:
0.    Program arguments: /usr/bin/clang-3.8 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name guard.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
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/bin/../lib/clang/3.8.1 -internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.8.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include --std=c++14 -fdeprecated-macro
-fdebug-compilation-dir /home/baluks -ferror-limit 19 -fmessage-length 134
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/guard-3aca29.o -x c++ guard.cpp 
1.    <eof> parser at end of file
2.    guard.cpp:16:6: instantiating function definition 'guard'
clang-3.8: error: unable to execute command: Segmentation fault (core dumped)
clang-3.8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.1 (tags/RELEASE_381/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-3.8: 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.8: 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.8: note: diagnostic msg: /tmp/guard-a4ea0e.cpp
clang-3.8: note: diagnostic msg: /tmp/guard-a4ea0e.sh
clang-3.8: note: diagnostic msg: 

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

/tmp/guard-a4ea0e.sh

# Crash reproducer for clang version 3.8.1 (tags/RELEASE_381/final)
# Driver args: "--driver-mode=g++" "--std=c++14" "guard.cpp"
# Original command:  "/usr/bin/clang-3.8" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "guard.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" "-dwarf-column-info" "-debugger-tuning=gdb"
"-resource-dir" "/usr/bin/../lib/clang/3.8.1" "-internal-isystem"
"/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1"
"-internal-isystem"
"/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu"
"-internal-isystem"
"/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/bin/../lib/clang/3.8.1/include" "-internal-externc-isystem" "/include"
"-internal-externc-isystem" "/usr/include" "--std=c++14" "-fdeprecated-macro"
"-fdebug-compilation-dir" "/home/baluks" "-ferror-limit" "19"
"-fmessage-length" "134" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/guard-3aca29.o"
"-x" "c++" "guard.cpp"
 "/usr/bin/clang-3.8" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj"
"-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name"
"guard.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"
"-dwarf-column-info" "-debugger-tuning=gdb" "--std=c++14" "-fdeprecated-macro"
"-ferror-limit" "19" "-fmessage-length" "134" "-fobjc-runtime=gcc"
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option"
"-fcolor-diagnostics" "-x" "c++" "guard-a4ea0e.cpp"

******

The following description may help.

I was trying to implement something similar to Haskell pattern guards using
templates. The guard() takes 2n arguments where the odd numbered ones are of
type bool and the even numbered ones are callable objects (To be called if and
only if the corresponding bool is true). All callable objects are supposed to
have the same type. And, I was checking what the compiler error/warning would
be if one callable returns int and another one returns a const char * in the
same guard() call. This produced the crash. Once I comment out the
type_mismatch variable definition in my source file, the program compiles
correctly and works as I expect.

I am running on Arch linux.

PS:- The crash report says to attach two files. However, the interface provided
here allows me to attach only one file.</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>