Skip to content

clang++ front end crash on combination of explicit object parameter, static_assert(): isInitialized() && "querying uninitialized conversion" #147121

Open
@m2

Description

@m2

I encountered this with clang 20.1.2, 20.1.7 as installed from the Ubuntu PPA. Trying on godbolt.org, the "assertions trunk" version encounters this but x86-64 20.1.0 does not, so an "assertions" build seems relevant.

With the following code as bug.cpp:

#include <iterator>

struct X
{};

struct S1
{
  using difference_type = int;

  template<typename Self>
  Self operator++(this Self&& self, int) {
    return self;
  }

  template<typename Self>
  bool operator==(this Self&& self, const X&) {
    return true;
  }
};

struct S2 : public S1
{
  using value_type = char;

  char operator*() const {
    return {};
  }

  S2& operator++() {
    return *this;
  }

  using S1::operator++;
};

int main()
{
  static_assert(std::weakly_incrementable<S2>); // crash                        

  return 0;
}

clang++ -std=c++2c -stdlib=libc++ bug.cpp
yields:

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: /usr/lib/llvm-20/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug.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 -debugger-tuning=gdb -fdebug-compilation-dir=/tmp -fcoverage-compilation-dir=/tmp -resource-dir /usr/lib/llvm-20/lib/clang/20 -internal-isystem /usr/lib/llvm-20/bin/../include/c++/v1 -internal-isystem /usr/lib/llvm-20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++2c -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug-a73dec.o -x c++ bug.cpp
1.	bug.cpp:39:46: current parser token ')'
2.	bug.cpp:38:1: parsing function body 'main'
3.	bug.cpp:38:1: in compound statement ('{}')
4.	/usr/lib/llvm-20/bin/../include/c++/v1/__iterator/incrementable_traits.h:64:8: instantiating class definition 'std::iterator_traits<S2>'
#0 0x000079eace21f816 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x101f816)
#1 0x000079eace21d410 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x101d410)
#2 0x000079eace21fecb (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x101fecb)
#3 0x000079eacca42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000079ead9262301 (/usr/lib/llvm-20/bin/../lib/libclang-cpp.so.20.1+0x3662301)
clang++: error: unable to execute command: Segmentation fault
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 20.1.7 (++20250613062716+6146a88f6049-1~exp1~20250613062748.129)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/bug-07fa73.cpp
clang++: note: diagnostic msg: /tmp/bug-07fa73.sh
clang++: note: diagnostic msg: 

********************

I intentionally didn't include the "PLEASE ATTACH" files yet because the requested .cpp is 760K and I'm assuming this can easily be reproduced with the source included above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++26clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]needs-reductionLarge reproducer that should be reduced into a simpler form

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions