<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/Sema/DeclSpec.cpp:1019 Assertion `(ExplicitSpec.getKind() == ExplicitSpecKind::ResolvedTrue || ExplicitSpec.getExpr()) && "invalid ExplicitSpecifier"' failed"
href="https://bugs.llvm.org/show_bug.cgi?id=46682">46682</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang crashed in clang/lib/Sema/DeclSpec.cpp:1019 Assertion `(ExplicitSpec.getKind() == ExplicitSpecKind::ResolvedTrue || ExplicitSpec.getExpr()) && "invalid ExplicitSpecifier"' 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>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 small code, with a little mistake, makes Clang-trunk crashed.
$cat test.cc
int b = 0;
int foo () { explicit ( && b );}
$clang++ test.cc
test.cc:2:23: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
int foo () { explicit ( && b );}
^
test.cc:2:25: error: conversion from 'void *' to 'bool' is not allowed in a
converted constant expression
int foo () { explicit ( && b );}
^~~~
clang-11: /home/haoxin/compilers/llvm-project/clang/lib/Sema/DeclSpec.cpp:1019:
bool clang::DeclSpec::setFunctionSpecExplicit(clang::SourceLocation, const char
*&, unsigned int &, clang::ExplicitSpecifier, clang::SourceLocation): Assertion
`(ExplicitSpec.getKind() == ExplicitSpecKind::ResolvedTrue ||
ExplicitSpec.getExpr()) && "invalid ExplicitSpecifier"' 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/compilers/llvm-project/build/bin/clang-11 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.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/compilers/llvm-project/build/lib/clang/11.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/compilers/llvm-project/build/lib/clang/11.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/bitbucket/scg-backup-bitbucket/ice-test/0711-test/creduce
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o /tmp/test-1e383d.o -x c++ test.cc
1. test.cc:2:31: current parser token ';'
2. test.cc:2:12: parsing function body 'foo'
3. test.cc:2:12: in compound statement ('{}')
#0 0x00000000027167d4 PrintStackTraceSignalHandler(void*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x27167d4)
#1 0x00000000027143ce llvm::sys::RunSignalHandlers()
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x27143ce)
#2 0x0000000002716af5 SignalHandler(int)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2716af5)
#3 0x00007fba9b2418a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#4 0x00007fba99c9ff47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#5 0x00007fba99ca18b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
#6 0x00007fba99c9142a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
#7 0x00007fba99c914a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
#8 0x0000000003f26fd4
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3f26fd4)
#9 0x0000000003e8021b
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e8021b)
#10 0x0000000003e7d1dd
clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*, clang::SourceLocation*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e7d1dd)
#11 0x0000000003e7cc5c
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e7cc5c)
#12 0x0000000003f0334a
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3f0334a)
#13 0x0000000003f02d72
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3f02d72)
#14 0x0000000003f0b021 clang::Parser::ParseCompoundStatementBody(bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3f0b021)
#15 0x0000000003f0bd80 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3f0bd80)
#16 0x0000000003e677fa
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e677fa)
#17 0x0000000003e82882 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e82882)
#18 0x0000000003e669bc
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e669bc)
#19 0x0000000003e66455
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e66455)
#20 0x0000000003e6523f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e6523f)
#21 0x0000000003e632ad
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e632ad)
#22 0x0000000003e5e6dd clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e5e6dd)
#23 0x0000000002ee8b03 clang::FrontendAction::Execute()
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2ee8b03)
#24 0x0000000002e7fd13
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2e7fd13)
#25 0x0000000002f94572
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2f94572)
#26 0x000000000095f45a cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95f45a)
#27 0x000000000095d4cc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95d4cc)
#28 0x000000000095d181 main
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95d181)
#29 0x00007fba99c82b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#30 0x000000000095a19a _start
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95a19a)
clang-11: error: unable to execute command: Aborted (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
51b0da731af75c68dd521e04cc576d5a611b1612)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
clang-11: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/test-4c413b.cpp
clang-11: note: diagnostic msg: /tmp/test-4c413b.sh
clang-11: note: diagnostic msg:
********************
$clang++ -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
51b0da731af75c68dd521e04cc576d5a611b1612)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.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.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64
This code only crashes Clang-trunk, Clang-10 or Clang-9 compiled fine on it, so
this is might be a regression issue.
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>