<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/147121>147121</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang++ front end crash on combination of explicit object parameter, static_assert()
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
m2
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysWF1z2zaz_jXwzQ40JKjPC1_QltV4Tt4TT-y2504DgksKNQjwAKAj3_S3v7OgZCm2kzRtZzQJCQLPPljsxwPLEHRrES_Z7IrN1hdyiDvnLztxUbn6-fIW0Co32Igea4g7HeCLjjtQRtoWRDbJJ4KJ6_FpATKAtiFKY7CGxrsO4g7h12qwcYC7u3ICD_5Z2xachdbVlTNx4nxLCDSRCSFDQB-1swGiH-wjEwKe0Aft7IlKGJlUQ4T9cs7n09F-BrXDANZFAgwOpP0aksCqQZsaAmIXwKPBJ2njhGUly8rfaWfEo3HGuC_EU7kaaVfV0E5U37OC5rF5dvhlJROFtsoMNQIrrnVEL6PzrLgZIUP0g4rwf_S2uGKLNSuuvvpynx8-ZSXAEMhmrZsGPVqF2_jcE-4atI0vKwEidr2REVlxTTOs7BDu0TSjWUjP4PoDF3GVfsvkszRNzJmYQ0iP1wlbrOBIAsBjHLwdvxfjIDEfjf_IduWcOdku1vT7tm3lbCD30OgLhYP96Ad8Zf8d_wlgRQn9UBmt3vPmkzTDmSPVTvozT9LrmadKJpZEZKT1xiPnR3juE7gXtKk3Hn_XrUyU5I13UEbC9zlFWVG-Qhs5nzlA2wid1Ha0c7bvEGXUajuGPRPLEOsR8QvKR_O81VZ57NBGWRk6xntBZydWrLgCJjZMbEB5GXZw5HUgnp04vMqBeZbqwcgUeDK4VuOrUGnA6IoVa6Orw_BLRo1QWfms0dThbYLdfbwp728gDFWnI0haBx575yNEB7sY-7Qo8W513A3VRLmOiY0xT8f_eO_dH6giExsdwoCB9ihtDcfUpaQf91xJ9Ri9VEjR2XvsvVMYAtYQ3ODHYVopQ3BKy4g1-MFCUF73qY7cR6keoR66Q7HIJixb3XnXetmB9O1AnifK5OsheKKoqyNRkTGxqehQN2OJ5UrlwKPXvUEqdtv5lPeKG22HPW_tABw7Hbmr_gBORmvtQXLgtQ50vLzxiMCVQem5DJFX2DiPn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