Skip to content

Clang 18 regression on C++20 mode: Unexpected placeholder builtin type! crash #122892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
egorpugin opened this issue Jan 14, 2025 · 4 comments · Fixed by #124609
Closed

Clang 18 regression on C++20 mode: Unexpected placeholder builtin type! crash #122892

egorpugin opened this issue Jan 14, 2025 · 4 comments · Fixed by #124609
Labels
c++20 clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash-on-invalid regression:18 Regression in 18 release

Comments

@egorpugin
Copy link

clang++ -v
clang version 20.0.0git (https://github.com/llvm/llvm-project c047a5b3f6e2295dd74f1e8f17f1a023150b246c)
Target: x86_64-pc-windows-msvc
Thread model: posix

clang++ main.cpp -std=c++20

struct A {
    void f() {
        l(r);
    }
    static void r() {}
    static auto l(auto &&f) {}    // error
  //static void l(auto &&f) {}    // ok
};

int main() {
    A k;
    k.f();
}
@Endilll
Copy link
Contributor

Endilll commented Jan 14, 2025

Confirmed on trunk. Regression since Clang 18 in C++20 mode (https://godbolt.org/z/a5sdrf77P):

<source>:3:9: error: cannot compile this l-value expression yet
    3 |         l(r);
      |         ^

Unexpected placeholder builtin type!
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenTypes.cpp:581!

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 -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:2:10: Generating code for declaration 'A::f'
 #0 0x0000000003ca32d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ca32d8)
 #1 0x0000000003ca0fe4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ca0fe4)
 #2 0x0000000003bed168 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007e7f41e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007e7f41e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007e7f41e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007e7f41e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000003bf8aca (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bf8aca)
 #8 0x000000000427967b clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x427967b)
 #9 0x0000000003fd98b0 clang::CodeGen::CodeGenFunction::EmitUnsupportedLValue(clang::Expr const*, char const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fd98b0)
#10 0x000000000400b285 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x400b285)
#11 0x000000000400bde7 void llvm::function_ref<void ()>::callback_fn<clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t)::'lambda'()>(long) CGExpr.cpp:0:0
#12 0x0000000007dfea01 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7dfea01)
#13 0x0000000003fd9bea clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fd9bea)
#14 0x00000000040054d8 clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40054d8)
#15 0x0000000004006bd3 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4006bd3)
#16 0x0000000004075134 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#17 0x0000000004068ff0 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#18 0x000000000406edac clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x406edac)
#19 0x0000000003fdfa6e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fdfa6e)
#20 0x000000000400511d clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x400511d)
#21 0x000000000414356e clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x414356e)
#22 0x000000000414b30c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x414b30c)
#23 0x00000000041b039c clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41b039c)
#24 0x00000000041c341e clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41c341e)
#25 0x000000000422befa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x422befa)
#26 0x0000000004227195 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4227195)
#27 0x0000000004232f8d clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4232f8d)
#28 0x0000000004235273 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4235273)
#29 0x00000000046329be (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#30 0x0000000004630745 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4630745)
#31 0x000000000664fd1c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664fd1c)
#32 0x0000000004630eb8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4630eb8)
#33 0x00000000048f1c75 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48f1c75)
#34 0x00000000048745ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48745ee)
#35 0x00000000049df0ae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49df0ae)
#36 0x0000000000cf134f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcf134f)
#37 0x0000000000ce8e2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#38 0x0000000004676f39 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
#39 0x0000000003bed614 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bed614)
#40 0x000000000467752f 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
#41 0x000000000463abed clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x463abed)
#42 0x000000000463bc6e 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+++0x463bc6e)
#43 0x0000000004643795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4643795)
#44 0x0000000000cee183 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcee183)
#45 0x0000000000bb9724 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbb9724)
#46 0x00007e7f41e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#47 0x00007e7f41e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#48 0x0000000000ce88d5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce88d5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@Endilll Endilll added c++20 crash-on-invalid regression:18 Regression in 18 release confirmed Verified by a second party and removed new issue labels Jan 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2025

@llvm/issue-subscribers-c-20

Author: Egor Pugin (egorpugin)

``` clang++ -v clang version 20.0.0git (https://github.com/llvm/llvm-project c047a5b) Target: x86_64-pc-windows-msvc Thread model: posix ```

clang++ main.cpp -std=c++20

struct A {
    void f() {
        l(r);
    }
    static void r() {}
    static auto l(auto &amp;&amp;f) {}    // error
  //static void l(auto &amp;&amp;f) {}    // ok
};

int main() {
    A k;
    k.f();
}

@Endilll Endilll changed the title cannot compile this l-value expression yet Clang 18 regression on C++20 mode: Unexpected placeholder builtin type! crash Jan 14, 2025
@Endilll Endilll added the clang:codegen IR generation bugs: mangling, exceptions, etc. label Jan 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2025

@llvm/issue-subscribers-clang-codegen

Author: Egor Pugin (egorpugin)

``` clang++ -v clang version 20.0.0git (https://github.com/llvm/llvm-project c047a5b) Target: x86_64-pc-windows-msvc Thread model: posix ```

clang++ main.cpp -std=c++20

struct A {
    void f() {
        l(r);
    }
    static void r() {}
    static auto l(auto &amp;&amp;f) {}    // error
  //static void l(auto &amp;&amp;f) {}    // ok
};

int main() {
    A k;
    k.f();
}

@shafik
Copy link
Collaborator

shafik commented Jan 14, 2025

@Fznamznon git bisect points to this commit at the cause of the regression: 20a0567

mizvekov pushed a commit that referenced this issue Mar 20, 2025
…inside non-dependent context (#124609)

The `UnresolvedLookupExpr` doesn't get looked up and resolved again
while it is inside the non-dependent context. It propagates into the
codegen phase, causing the assertion failure.

We attempt to determine if the current context is dependent before
moving on with the substitution introduced in the
20a0567.

This fixes #122892.

---------

Co-authored-by: Sirraide <[email protected]>
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this issue Mar 20, 2025
…LookupExpr inside non-dependent context (#124609)

The `UnresolvedLookupExpr` doesn't get looked up and resolved again
while it is inside the non-dependent context. It propagates into the
codegen phase, causing the assertion failure.

We attempt to determine if the current context is dependent before
moving on with the substitution introduced in the
llvm/llvm-project@20a0567.

This fixes llvm/llvm-project#122892.

---------

Co-authored-by: Sirraide <[email protected]>
@frederick-vs-ja frederick-vs-ja marked this as a duplicate of #133252 Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash-on-invalid regression:18 Regression in 18 release
Projects
None yet
4 participants