<html>
<head>
<base href="https://bugs.llvm.org/">
</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 crashed in clang/lib/AST/NestedNameSpecifier.cpp:79. Assertion '(!Prefix || (Prefix->getAsType() == nullptr && Prefix->getAsIdentifier() == nullptr)) && "Broken nested name specifier"' failed"
href="https://bugs.llvm.org/show_bug.cgi?id=46988">46988</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang crashed in clang/lib/AST/NestedNameSpecifier.cpp:79. Assertion '(!Prefix || (Prefix->getAsType() == nullptr && Prefix->getAsIdentifier() == nullptr)) && "Broken nested name specifier"' failed
</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>Keywords</th>
<td>crash-on-invalid
</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>haoxintu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Hi, all.
This code makes Clang-trunk crashed, while other released versions compile it
normally. Weirdly, this issue might be caused by the identifier name in
namespace definition.
Input:
//small.cc
namespace
var_var_var_var_var_1var_ {
class var_ {
var_::var_var_var_var_var_ ::
}
Command:
clang++ small.cc
Output:
small.cc:4:5: error: no member named 'var_var_var_var_var_' in
'var_var_var_var_var_1var_::var_'; did you mean 'var_var_var_var_var_1var_'?
var_::var_var_var_var_var_ ::
^~~~~~~~~~~~~~~~~~~~~~~~~~
var_var_var_var_var_1var_
small.cc:2:1: note: 'var_var_var_var_var_1var_' declared here
var_var_var_var_var_1var_ {
^
clang-12:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/clang/lib/AST/NestedNameSpecifier.cpp:79:
static clang::NestedNameSpecifier *clang::NestedNameSpecifier::Create(const
clang::ASTContext &, clang::NestedNameSpecifier *, const clang::NamespaceDecl
*): Assertion `(!Prefix || (Prefix->getAsType() == nullptr &&
Prefix->getAsIdentifier() == nullptr)) && "Broken nested name specifier"'
failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name small.cc -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/lib/clang/12.0.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/lib/clang/12.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 /home/haoxin/test/clang-bug
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o /tmp/small-0d0f29.o -x c++ small.cc
1. small.cc:5:1: current parser token '}'
2. small.cc:1:1: parsing namespace 'var_var_var_var_var_1var_'
3. small.cc:3:1: parsing struct/union/class body
'var_var_var_var_var_1var_::var_'
#0 0x0000000002758f44 PrintStackTraceSignalHandler(void*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2758f44)
#1 0x0000000002756b4e llvm::sys::RunSignalHandlers()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2756b4e)
#2 0x0000000002759265 SignalHandler(int)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2759265)
#3 0x00007f57615e6390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f5760150438 raise
/build/glibc-e6zv40/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f576015203a abort /build/glibc-e6zv40/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f5760148be7 __assert_fail_base
/build/glibc-e6zv40/glibc-2.23/assert/assert.c:92:0
#7 0x00007f5760148c92 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc92)
#8 0x0000000004d1b10e
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4d1b10e)
#9 0x0000000004d1c3f3
clang::NestedNameSpecifierLocBuilder::Extend(clang::ASTContext&,
clang::NamespaceDecl*, clang::SourceLocation, clang::SourceLocation)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4d1c3f3)
#10 0x0000000004085d9c clang::CXXScopeSpec::Extend(clang::ASTContext&,
clang::NamespaceDecl*, clang::SourceLocation, clang::SourceLocation)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4085d9c)
#11 0x00000000040dcf30 clang::Sema::BuildCXXNestedNameSpecifier(clang::Scope*,
clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&,
clang::NamedDecl*, bool, bool*, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x40dcf30)
#12 0x00000000040ddb43 clang::Sema::ActOnCXXNestedNameSpecifier(clang::Scope*,
clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&, bool, bool*,
bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x40ddb43)
#13 0x000000000401d899
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool,
clang::IdentifierInfo**, bool, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x401d899)
#14 0x0000000003fca8ac clang::Parser::TryAnnotateCXXScopeToken(bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fca8ac)
#15 0x0000000004000fcb
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4000fcb)
#16 0x00000000040045b4
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x40045b4)
#17 0x0000000003ffe5dd
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3ffe5dd)
#18 0x0000000003ffc1d1
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3ffc1d1)
#19 0x0000000003fdc53a
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fdc53a)
#20 0x0000000003fc53fa
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc53fa)
#21 0x0000000003fc5125
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc5125)
#22 0x0000000003fc3f0f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc3f0f)
#23 0x0000000003ff5acb
clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo,
4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&,
clang::BalancedDelimiterTracker&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3ff5acb)
#24 0x0000000003ff542a clang::Parser::ParseNamespace(clang::DeclaratorContext,
clang::SourceLocation&, clang::SourceLocation)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3ff542a)
#25 0x0000000003fdbbc7
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fdbbc7)
#26 0x0000000003fc35ba
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc35ba)
#27 0x0000000003fc1f7d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc1f7d)
#28 0x0000000003fc17c7
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc17c7)
#29 0x0000000003fbd27e clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fbd27e)
#30 0x0000000002f2a393 clang::FrontendAction::Execute()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2f2a393)
#31 0x0000000002ec4ea3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2ec4ea3)
#32 0x0000000002fd43b2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2fd43b2)
#33 0x0000000000983453 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x983453)
#34 0x00000000009818ec ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x9818ec)
#35 0x0000000000981594 main
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x981594)
#36 0x00007f576013b840 __libc_start_main
/build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:325:0
#37 0x000000000097e5a9 _start
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x97e5a9)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin
clang-12: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/small-802340.cpp
clang-12: note: diagnostic msg: /tmp/small-802340.sh
clang-12: note: diagnostic msg:
********************
Thanks,
Haoxin</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>