llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.81k stars 11.91k forks source link

Error using “clang hello.cpp -o hello -lstdc++ -ccc-print-phases” in WSL Ubuntu 24.04 LTS #99447

Open 17789289 opened 3 months ago

17789289 commented 3 months ago

using command : clang hello.cpp -o hello -lstdc++ is OK, but:

clang hello.cpp -o hello -lstdc++ -ccc-print-phases +- 0: input, "hello.cpp", c++ +- 1: preprocessor, {0}, c++-cpp-output +- 2: compiler, {1}, ir +- 3: backend, {2}, assembler +- 4: assembler, {3}, object clang: /home/qiwei/llvm-project/llvm/include/llvm/ADT/SmallVector.h:308: const_reference llvm::SmallVectorTemplateCommon<const char >::operator const [T = const char ]: Assertion `idx < size()' failed.

EugeneZelenko commented 3 months ago

Could you please provide version information, complete crash stack and reproducer, preferably on https://godbolt.org?

17789289 commented 3 months ago

Below is my code,it's very simple:

include

int main() { std::cout << "Hello world!" << std::endl; return 0; }

the issue was occurred at WSL Ubuntu 24.04 LTS platform with Clang 18.1.8

what I have done so far: just run the same code and command (clang hello.cpp -o hello -lstdc++ -ccc-print-phases) in WSL Ubuntu 22.04 LTS platform with clang14, no issue found in the result. But when I run the same command using clang17 and clang18.1.8, same issue raised:

clang hello.cpp -o hello -lstdc++ -ccc-print-phases +- 0: input, "hello.cpp", c++ +- 1: preprocessor, {0}, c++-cpp-output +- 2: compiler, {1}, ir +- 3: backend, {2}, assembler +- 4: assembler, {3}, object clang: /home/qiwei/llvm-project/llvm/include/llvm/ADT/SmallVector.h:308: llvm::SmallVectorTemplateCommon::const_reference llvm::SmallVectorTemplateCommon<const char >::operator const [T = const char ]: Assertion `idx < size()' 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:

  1. Program arguments: clang hello.cpp -o hello -lstdc++ -ccc-print-phases
  2. Compilation construction

    0 0x00007f9b565aa277 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/qiwei/llvm-project/install/bin/../lib/libLLVMSupport.so.18.1+0x203277)

    1 0x00007f9b565a7dde llvm::sys::RunSignalHandlers() (/home/qiwei/llvm-project/install/bin/../lib/libLLVMSupport.so.18.1+0x200dde)

    2 0x00007f9b565aa94a SignalHandler(int) Signals.cpp:0:0

    3 0x00007f9b55e86520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)

    4 0x00007f9b55eda9fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)

    5 0x00007f9b55e86476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)

    6 0x00007f9b55e6c7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)

    7 0x00007f9b55e6c71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)

    8 0x00007f9b55e7de96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)

    9 0x00007f9b58f4f0e9 llvm::SmallVectorTemplateCommon<char const*, void>::operator[](unsigned long) const /home/qiwei/llvm-project/llvm/include/llvm/ADT/SmallVector.h:0:5

    10 0x00007f9b58f8d021 llvm::opt::Arg::getValue(unsigned int) const /home/qiwei/llvm-project/llvm/include/llvm/Option/Arg.h:126:12

    11 0x00007f9b58f77210 PrintActions1(clang::driver::Compilation const&, clang::driver::Action, std::map<clang::driver::Action, unsigned int, std::less<clang::driver::Action>, std::allocator<std::pair<clang::driver::Action const, unsigned int>>>&, llvm::Twine, int) /home/qiwei/llvm-project/clang/lib/Driver/Driver.cpp:2326:37

    12 0x00007f9b58f77542 PrintActions1(clang::driver::Compilation const&, clang::driver::Action, std::map<clang::driver::Action, unsigned int, std::less<clang::driver::Action>, std::allocator<std::pair<clang::driver::Action const, unsigned int>>>&, llvm::Twine, int) /home/qiwei/llvm-project/clang/lib/Driver/Driver.cpp:2359:25

    13 0x00007f9b58f71ba6 clang::driver::Driver::PrintActions(clang::driver::Compilation const&) const /home/qiwei/llvm-project/clang/lib/Driver/Driver.cpp:2398:18

    14 0x00007f9b58f6d4eb clang::driver::Driver::BuildCompilation(llvm::ArrayRef<char const*>) /home/qiwei/llvm-project/clang/lib/Driver/Driver.cpp:1518:12

    15 0x000055839f2dfaf1 clang_main(int, char**, llvm::ToolContext const&) /home/qiwei/llvm-project/clang/tools/driver/driver.cpp:510:44

    16 0x000055839f316bd5 main /home/qiwei/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:17:3

    17 0x00007f9b55e6dd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)

    18 0x00007f9b55e6de40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)

    19 0x000055839f2debb5 _start (/home/qiwei/llvm-project/install/bin/clang-18+0x42bb5)

    Aborted

llvmbot commented 3 months ago

@llvm/issue-subscribers-clang-driver

Author: Dynpro (17789289)

using command : clang hello.cpp -o hello -lstdc++ is OK, but: clang hello.cpp -o hello -lstdc++ -ccc-print-phases +- 0: input, "hello.cpp", c++ +- 1: preprocessor, {0}, c++-cpp-output +- 2: compiler, {1}, ir +- 3: backend, {2}, assembler +- 4: assembler, {3}, object clang: /home/qiwei/llvm-project/llvm/include/llvm/ADT/SmallVector.h:308: const_reference llvm::SmallVectorTemplateCommon<const char *>::operator[](size_type) const [T = const char *]: Assertion `idx < size()' failed.