[llvm-bugs] [Bug 28368] New: clang crashes on valid (?) C++11 code with variadic template: Assertion `StartColNo <= EndColNo && "Trying to highlight whitespace??"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 29 23:47:59 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28368

            Bug ID: 28368
           Summary: clang crashes on valid (?) C++11 code with variadic
                    template: Assertion `StartColNo <= EndColNo && "Trying
                    to highlight whitespace??"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following C++11 test case on
x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It crashes all clang versions since at least as early as 3.1.x. 


$ clang++ -v
clang version 3.9.0 (trunk 274113)
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
$
$ g++-6.1 -c -std=c++11 small.cpp
$
$ clang++ -c -std=c++11 small.cpp
small.cpp:5:24: error: excess elements in scalar initializer
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Frontend/TextDiagnostic.cpp:978:
void highlightRange(const clang::CharSourceRange&, unsigned int, clang::FileID,
const {anonymous}::SourceColumnMap&, std::string&, const clang::SourceManager&,
const clang::LangOptions&): Assertion `StartColNo <= EndColNo && "Trying to
highlight whitespace??"' failed.
#0 0x0000000001d30e95 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d30e95)
#1 0x0000000001d2ed26 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1d2ed26)
#2 0x0000000001d2ef44 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d2ef44)
#3 0x00007f5b6812b340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f5b66f1ccc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f5b66f200d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f5b66f15b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f5b66f15c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x000000000223b451
clang::TextDiagnostic::emitSnippetAndCaret(clang::SourceLocation,
clang::DiagnosticsEngine::Level,
llvm::SmallVectorImpl<clang::CharSourceRange>&,
llvm::ArrayRef<clang::FixItHint>, clang::SourceManager const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x223b451)
#9 0x0000000002232032
clang::DiagnosticRenderer::emitCaret(clang::SourceLocation,
clang::DiagnosticsEngine::Level, llvm::ArrayRef<clang::CharSourceRange>,
llvm::ArrayRef<clang::FixItHint>, clang::SourceManager const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2232032)
#10 0x0000000002232f93
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*>)
(/usr/local/clang-trunk/bin/clang-3.9+0x2232f93)
#11 0x00000000021eb44e
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&) (/usr/local/clang-trunk/bin/clang-3.9+0x21eb44e)
#12 0x0000000001e45974
clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&,
clang::DiagnosticIDs::Level) const
(/usr/local/clang-trunk/bin/clang-3.9+0x1e45974)
#13 0x0000000001e45c63
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const
(/usr/local/clang-trunk/bin/clang-3.9+0x1e45c63)
#14 0x0000000001e3cecc clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x1e3cecc)
#15 0x0000000002a298ed clang::Sema::EmitCurrentDiagnostic(unsigned int)
(/usr/local/clang-trunk/bin/clang-3.9+0x2a298ed)
#16 0x00000000029f3a8b
clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder()
(/usr/local/clang-trunk/bin/clang-3.9+0x29f3a8b)
#17 0x0000000002c9954a clang::InitializationSequence::Diagnose(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::ArrayRef<clang::Expr*>) (/usr/local/clang-trunk/bin/clang-3.9+0x2c9954a)
#18 0x0000000002c9cdd5 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2c9cdd5)
#19 0x0000000002c2a350
clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation) (/usr/local/clang-trunk/bin/clang-3.9+0x2c2a350)
#20 0x0000000002e44de4 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXUnresolvedConstructExpr(clang::CXXUnresolvedConstructExpr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e44de4)
#21 0x0000000002e357ab clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e357ab)
#22 0x0000000002e36ea8 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e36ea8)
#23 0x0000000002e37224 clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e37224)
#24 0x0000000002e63eb5
clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*,
clang::MultiLevelTemplateArgumentList const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e63eb5)
#25 0x0000000002e6cf2b clang::Sema::BuildVariableInstantiation(clang::VarDecl*,
clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&,
llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*,
clang::DeclContext*, clang::LocalInstantiationScope*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e6cf2b)
#26 0x0000000002e6d797
clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e6d797)
#27 0x0000000002e40912 clang::Sema::InstantiateClass(clang::SourceLocation,
clang::CXXRecordDecl*, clang::CXXRecordDecl*,
clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e40912)
#28 0x0000000002e5c924
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2e5c924)
#29 0x0000000002e99aef
clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType,
clang::Sema::TypeDiagnoser*) (/usr/local/clang-trunk/bin/clang-3.9+0x2e99aef)
#30 0x0000000002e99db5 clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, clang::Sema::TypeDiagnoser&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e99db5)
#31 0x0000000002e99f93 clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, unsigned int) (/usr/local/clang-trunk/bin/clang-3.9+0x2e99f93)
#32 0x0000000002ae9130 clang::Sema::ActOnUninitializedDecl(clang::Decl*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2ae9130)
#33 0x0000000002830d16
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2830d16)
#34 0x000000000283efd5 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-3.9+0x283efd5)
#35 0x000000000281b4bd
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-3.9+0x281b4bd)
#36 0x000000000281bb61
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.222]
(/usr/local/clang-trunk/bin/clang-3.9+0x281bb61)
#37 0x000000000281bb9f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-3.9+0x281bb9f)
#38 0x0000000002820a10
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-3.9+0x2820a10)
#39 0x00000000028211e0
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-3.9+0x28211e0)
#40 0x000000000281880b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x281880b)
#41 0x00000000024a12de clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x24a12de)
#42 0x00000000021aeb4e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x21aeb4e)
#43 0x00000000021842f6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x21842f6)
#44 0x000000000223bec2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x223bec2)
#45 0x0000000000afd2d8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xafd2d8)
#46 0x0000000000ab04dc main (/usr/local/clang-trunk/bin/clang-3.9+0xab04dc)
#47 0x00007f5b66f07ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#48 0x0000000000af9344 _start (/usr/local/clang-trunk/bin/clang-3.9+0xaf9344)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -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/3.9.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/3.9.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 117
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp
1.      small.cpp:8:19: current parser token ';'
2.      small.cpp:3:33: instantiating class definition 'A<short, int>'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 274113)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-3.9: 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.9: 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.9: note: diagnostic msg: /tmp/small-6da835.cpp
clang-3.9: note: diagnostic msg: /tmp/small-6da835.sh
clang-3.9: note: diagnostic msg:

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


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


template < class > constexpr int foo () {  return 0; }

template < class ... T > struct A
{ 
  static const int f = int (foo < T > () ...);
};

A < short, int > a;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160630/347e1373/attachment-0001.html>


More information about the llvm-bugs mailing list