<html>
    <head>
      <base href="http://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 --- - Arbitrary error (with comment) causes clang frontend assert"
   href="http://llvm.org/bugs/show_bug.cgi?id=19920">19920</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Arbitrary error (with comment) causes clang frontend assert
          </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>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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>pkeir@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12591" name="attach_12591" title="The c++ file which produces the frontend error">attachment 12591</a> <a href="attachment.cgi?id=12591&action=edit" title="The c++ file which produces the frontend error">[details]</a></span>
The c++ file which produces the frontend error

An arbitrary error combined with a following comment produces an assert from
the frontend of clang++. For example, this code (also attached):

void q()
{
  int i = _123456; // error... ‘int&’ from expression of type ‘const int’
}

compiled with:

clang++ -c clangparsecommentbug.cpp

produces the error messages below. It seems that the position and content of
the comment is involved. Removing the comment, for example, removes the assert.

Here is the output:

clangparsecommentbug.cpp:3:11: error: use of undeclared identifier '_123456'
clang:
/home/X/projects/llvm_src/llvm_trunk/Mon-02-Jun-2014--12-15-23/llvm/tools/clang/lib/Frontend/TextDiagnostic.cpp:296:
int <anonymous namespace>::SourceColumnMap::startOfNextColumn(int) const:
Assertion `0 <= N && N < static_cast<int>(m_columnToByte.size() - 1)' failed.
0  clang           0x00000000025eb535 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang           0x00000000025ebc83
2  libpthread.so.0 0x00007f490465d340
3  libc.so.6       0x00007f4903899f79 gsignal + 57
4  libc.so.6       0x00007f490389d388 abort + 328
5  libc.so.6       0x00007f4903892e36
6  libc.so.6       0x00007f4903892ee2
7  clang           0x000000000074d0da
8  clang           0x00000000007423cb
clang::DiagnosticRenderer::emitDiagnostic(clang::SourceLocation,
clang::DiagnosticsEngine::Level, llvm::StringRef,
llvm::ArrayRef<clang::CharSourceRange>, llvm::ArrayRef<clang::FixItHint>,
clang::SourceManager const*, llvm::PointerUnion<clang::Diagnostic const*,
clang::StoredDiagnostic const*>) + 1739
9  clang           0x0000000000710c71
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&) + 1521
10 clang           0x00000000016095fc
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const + 588
11 clang           0x00000000016045ea
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) + 90
12 clang           0x0000000000b33f58
clang::Sema::EmitCurrentDiagnostic(unsigned int) + 904
13 clang           0x0000000000cbfae2
clang::Sema::DiagnoseEmptyLookup(clang::Scope*, clang::CXXScopeSpec&,
clang::LookupResult&, clang::CorrectionCandidateCallback&,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>) + 3842
14 clang           0x0000000000cb9626
clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&,
clang::SourceLocation, clang::UnqualifiedId&, bool, bool,
clang::CorrectionCandidateCallback*, bool) + 2054
15 clang           0x0000000000ac4d5a clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 9530
16 clang           0x0000000000abfd30
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 128
17 clang           0x0000000000a9e60b
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) + 3851
18 clang           0x0000000000a9c5c0
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1744
19 clang           0x0000000000a9859c
clang::Parser::ParseSimpleDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*)
+ 668
20 clang           0x0000000000a9823c
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 876
21 clang           0x0000000000af6434
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 2884
22 clang           0x0000000000af5850
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 144
23 clang           0x0000000000afcf01
clang::Parser::ParseCompoundStatementBody(bool) + 1553
24 clang           0x0000000000b006ed
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 189
25 clang           0x0000000000a8ac16
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
1878
26 clang           0x0000000000a9c41f
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1327
27 clang           0x0000000000a8a23d
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 797
28 clang           0x0000000000a89c03
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 403
29 clang           0x0000000000a88d0c
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 3036
30 clang           0x0000000000a88038
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 504
31 clang           0x0000000000a83f20 clang::ParseAST(clang::Sema&, bool, bool)
+ 256
32 clang           0x00000000008b01ce clang::CodeGenAction::ExecuteAction() +
142
33 clang           0x00000000006e9be2 clang::FrontendAction::Execute() + 66
34 clang           0x00000000006c030d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 941
35 clang           0x00000000006a5668
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3064
36 clang           0x000000000069cb88 cc1_main(char const**, char const**, char
const*, void*) + 696
37 clang           0x00000000006a34a5 main + 9205
38 libc.so.6       0x00007f4903884ec5 __libc_start_main + 245
39 clang           0x000000000069c809
Stack dump:
0.  Program arguments:
/home/X/projects/llvm_src/llvm_trunk/Mon-02-Jun-2014--12-15-23/install/bin/clang
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name clangparsecommentbug.cpp -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24
-coverage-file /home/X/code/cpp/clangparsecommentbug.o -resource-dir
/home/X/projects/llvm_src/llvm_trunk/Mon-02-Jun-2014--12-15-23/install/bin/../lib/clang/3.5.0
-c-isystem /opt/intel/opencl-1.2-3.1.1.11385/include -c-isystem . -cxx-isystem
/home/X/code/boost_1_53_0 -cxx-isystem . -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
-internal-isystem /usr/local/include -internal-isystem
/home/X/projects/llvm_src/llvm_trunk/Mon-02-Jun-2014--12-15-23/install/bin/../lib/clang/3.5.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 /home/X/code/cpp -ferror-limit 19
-fmessage-length 80 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -o clangparsecommentbug.o -x c++
clangparsecommentbug.cpp 
1.  clangparsecommentbug.cpp:3:18: current parser token ';'
2.  clangparsecommentbug.cpp:2:1: parsing function body 'q'
3.  clangparsecommentbug.cpp:2:1: in compound statement ('{}')
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5.0 (trunk 210014)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: 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: 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: /tmp/clangparsecommentbug-e07bdf.cpp
clang: note: diagnostic msg: /tmp/clangparsecommentbug-e07bdf.sh
clang: 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>