Issue |
128384
|
Summary |
__has_embed: Assertion `Length < Tok.getLength() && "NeedsCleaning flag set on token that didn't need cleaning!"' failed.
|
Labels |
new issue
|
Assignees |
|
Reporter |
hubert-reinterpretcast
|
With an assertions-enabled build, an assertion failure is observed for a valid use of `__has_embed` which uses line splicing. Compiler Explorer link: https://godbolt.org/z/xKc5Txa4n
### Source (`<stdin>`)
```cpp
#if __has_embed(__FILE__\
)
int
#else
int
#endif
main() {}
```
### Compiler Invocation
```
clang++ -E -Wall -Wextra -pedantic -v -xc++ -
```
### Actual Compiler Output
```
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 5f8da7e7738f043dbde447e48622e9b2afb5ba92)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk-20250222/bin
Build config: +assertions
Found candidate GCC installation: /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1
Selected GCC installation: /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
clang++: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
(in-process)
"/opt/compiler-explorer/clang-assertions-trunk-20250222/bin/clang-21" -cc1 -triple x86_64-unknown-linux-gnu -E -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -v -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20250222/lib/clang/21 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/backward -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20250222/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -pedantic -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x c++ <source>
clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/x86_64-linux-gnu
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/backward
/opt/compiler-explorer/clang-assertions-trunk-20250222/lib/clang/21/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
clang++: /root/llvm-project/clang/lib/Lex/Lexer.cpp:368: size_t getSpellingSlow(const clang::Token&, const char*, const clang::LangOptions&, char*): Assertion `Length < Tok.getLength() && "NeedsCleaning flag set on token that didn't need cleaning!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -fverbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -E -Wall -Wextra -pedantic -v <source>
#0 0x0000000003e46cb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e46cb8)
#1 0x0000000003e44974 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e44974)
#2 0x0000000003d90d78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000071ac1de42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000071ac1de969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000071ac1de42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000071ac1de287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000071ac1de2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000071ac1de39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007b67d4c (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b67d4c)
#10 0x0000000007b67e19 clang::Lexer::getSpelling(clang::Token const&, char const*&, clang::SourceManager const&, clang::LangOptions const&, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b67e19)
#11 0x0000000007bfccdd clang::Preprocessor::getSpelling(clang::Token const&, llvm::SmallVectorImpl<char>&, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bfccdd)
#12 0x0000000007bc7710 EvaluateValue((anonymous namespace)::PPValue&, clang::Token&, DefinedTracker&, bool, clang::Preprocessor&) PPExpressions.cpp:0:0
#13 0x0000000007bcc3ab clang::Preprocessor::EvaluateDirectiveExpression(clang::IdentifierInfo*&, clang::Token&, bool&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bcc3ab)
#14 0x0000000007bccf1f clang::Preprocessor::EvaluateDirectiveExpression(clang::IdentifierInfo*&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bccf1f)
#15 0x0000000007bbea9f clang::Preprocessor::HandleIfDirective(clang::Token&, clang::Token const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bbea9f)
#16 0x0000000007bc3b78 clang::Preprocessor::HandleDirective(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bc3b78)
#17 0x0000000007b73e4a clang::Lexer::LexTokenInternal(clang::Token&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b73e4a)
#18 0x0000000007b7600f clang::Lexer::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b7600f)
#19 0x0000000007c0766c clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7c0766c)
#20 0x0000000004b17758 clang::DoPrintPreprocessedInput(clang::Preprocessor&, llvm::raw_ostream*, clang::PreprocessorOutputOptions const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b17758)
#21 0x0000000004aea00e clang::PrintPreprocessedAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4aea00e)
#22 0x0000000004acfad5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4acfad5)
#23 0x0000000004a5329e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a5329e)
#24 0x0000000004bbe52e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bbe52e)
#25 0x0000000000d3a00f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd3a00f)
#26 0x0000000000d31a8a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x000000000484e3d9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x0000000003d91224 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d91224)
#29 0x000000000484e9cf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x00000000048112cd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48112cd)
#31 0x000000000481234e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481234e)
#32 0x000000000481a2e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481a2e5)
#33 0x0000000000d36e03 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd36e03)
#34 0x0000000000c08aa4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc08aa4)
#35 0x000071ac1de29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x000071ac1de29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000d31535 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd31535)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
### Expected Compiler Input
(successful preprocessing)
### Compiler Version Info
(see output above)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs