<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 on invalid C++ code with an undeclared function as parameter to __remove_copy_if: in clang::Sema::CorrectDelayedTyposInExpr"
   href="https://llvm.org/bugs/show_bug.cgi?id=28708">28708</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on invalid C++ code with an undeclared function as parameter to __remove_copy_if: in clang::Sema::CorrectDelayedTyposInExpr
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>su@cs.ucdavis.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The current clang trunk crashes when compiling the following C++ test case on
x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It is a regression from 3.8.x, which properly rejects the code.


$ clang++ -v
clang version 4.0.0 (trunk 276574)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang++-3.8 -c small.cpp
small.cpp:4:21: error: use of undeclared identifier '_S_on_swap'
  __remove_copy_if (_S_on_swap, res);
                    ^
1 error generated.
$
$ clang++ -c small.cpp
clang-4.0:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Sema/SemaExprCXX.cpp:6963:
clang::ExprResult clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*,
llvm::function_ref<clang::ActionResult<clang::Expr*>(clang::Expr*)>): Assertion
`TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"' failed.
#0 0x0000000001d6c945 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d6c945)
#1 0x0000000001d6a9fe llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1d6a9fe)
#2 0x0000000001d6ab60 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d6ab60)
#3 0x00007f923ddcc340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f923cbbdcc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f923cbc10d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f923cbb6b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f923cbb6c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000002c71e32 clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true>
(clang::Expr*)>) (/usr/local/clang-trunk/bin/clang-4.0+0x2c71e32)
#9 0x0000000002c229d0 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2c229d0)
#10 0x0000000002c8a46d clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformCallExpr(clang::CallExpr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2c8a46d)
#11 0x0000000002c735cf clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2c735cf)
#12 0x0000000002c741f9 (anonymous
namespace)::TransformTypos::TryTransform(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2c741f9)
#13 0x0000000002c70c2d clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true>
(clang::Expr*)>) (/usr/local/clang-trunk/bin/clang-4.0+0x2c70c2d)
#14 0x0000000002c71f73 clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2c71f73)
#15 0x0000000002d9d330
clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>)
(/usr/local/clang-trunk/bin/clang-4.0+0x2d9d330)
#16 0x00000000028d0b4d clang::Parser::ParseExprStatement()
(/usr/local/clang-trunk/bin/clang-4.0+0x28d0b4d)
#17 0x00000000028cdff7
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-4.0+0x28cdff7)
#18 0x00000000028ce14e
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*)
(/usr/local/clang-trunk/bin/clang-4.0+0x28ce14e)
#19 0x00000000028d2ac9 clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x28d2ac9)
#20 0x00000000028d5309 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-4.0+0x28d5309)
#21 0x000000000285259b
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x285259b)
#22 0x00000000028e2ab8
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x28e2ab8)
#23 0x00000000028e3737
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x28e3737)
#24 0x00000000028e3aaa
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x28e3aaa)
#25 0x00000000028754d4 clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-4.0+0x28754d4)
#26 0x0000000002853732
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-4.0+0x2853732)
#27 0x0000000002853ee0
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x2853ee0)
#28 0x000000000284b490 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x284b490)
#29 0x00000000024e941e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x24e941e)
#30 0x00000000021f8a9e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x21f8a9e)
#31 0x00000000021ce666
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x21ce666)
#32 0x0000000002285612
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2285612)
#33 0x0000000000b1e8f0 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb1e8f0)
#34 0x0000000000accfe2 main (/usr/local/clang-trunk/bin/clang-4.0+0xaccfe2)
#35 0x00007f923cba8ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#36 0x0000000000b1a8d4 _start (/usr/local/clang-trunk/bin/clang-4.0+0xb1a8d4)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.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
-coverage-file /data2/small.cpp -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/4.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/4.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 199
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp
1.      small.cpp:5:1: current parser token '}'
2.      small.cpp:2:1: parsing function body 'foo'
3.      small.cpp:2:1: in compound statement ('{}')
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 276574)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.0: 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-4.0: note: diagnostic msg:
********************

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

********************
$


-----------------------------------------


template < typename T > void foo ()

  T res;
  __remove_copy_if (_S_on_swap, res);
}</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>