Issue 239457
Summary [clang] Assertion `!IsAtEnd() && "No token on the RHS of a paste operator!"' failed.
Labels clang:frontend, crash, generated by fuzzer
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/r1nvbjvMT
```cpp
#define FOO(x, y) x####y
FOO(bar, )
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Lex/TokenLexer.cpp:793: bool clang::TokenLexer::pasteTokens(clang::Token&, llvm::ArrayRef<clang::Token>, unsigned int&): Assertion `!IsAtEnd() && "No token on the RHS of a paste operator!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<source>:2:1 <Spelling=<source>:2:5>: current parser token 'bar'
 #0 0x0000000004f0d918 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f0d918)
 #1 0x0000000004f0ab74 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f0ab74)
 #2 0x0000000004f0b1ac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f0b1ac)
 #3 0x0000000004e44f28 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007fc945445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007fc94549ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
 #6 0x00007fc94544527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007fc9454288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x00007fc94542881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x00007fc94543b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000aa9d09b clang::TokenLexer::pasteTokens(clang::Token&, llvm::ArrayRef<clang::Token>, unsigned int&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xaa9d09b)
#11 0x000000000aa9d83f clang::TokenLexer::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xaa9d83f)
#12 0x000000000aa9340c clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xaa9340c)
#13 0x0000000008fa1fc2 clang::Parser::ConsumeToken() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8fa1fc2)
#14 0x0000000008f8dd11 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8f8dd11)
#15 0x0000000005a090c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a090c8)
#16 0x0000000005d314d8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d314d8)
#17 0x0000000005cbdf4d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5cbdf4d)
#18 0x0000000005e07b33 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e07b33)
#19 0x0000000001716cf8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1716cf8)
#20 0x000000000170dbda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#21 0x000000000170dd63 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#22 0x0000000005a812b9 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
#23 0x0000000004e45324 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e45324)
#24 0x0000000005a81e25 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
#25 0x0000000005a3ec42 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a3ec42)
#26 0x0000000005a41efc 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+++0x5a41efc)
#27 0x0000000005a4e3f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a4e3f5)
#28 0x000000000171332a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x171332a)
#29 0x0000000001688dc3 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1688dc3)
#30 0x00007fc94542a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#31 0x00007fc94542a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#32 0x000000000170d585 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x170d585)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to