Skip to content

[Clang] Clang hangs when compiling valid code involving std::thread and lambda with --std=c++23 #151451

@Xniao

Description

@Xniao

Clang trunk hangs when compiling following program under C++23 mode. The same code compiles successfully and quickly with --std=c++20.

Program

#include <thread>

int main() {
    std::thread memory_thread([]() {
      const int alloc_size = 1024 * 1024;
      while (true) {
        char *buffer = new char[alloc_size];
        if (buffer == nullptr)
          break;
        delete[] buffer;
      }
    });
  return 0;
}

Here is the repro: https://godbolt.org/z/4v1c5Wreq

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyconstexprAnything related to constant evaluationgenerated by fuzzerhangCompiler hang (infinite loop)regression:20Regression in 20 release

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions