<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/140934>140934</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
trunk regression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
scarf005
</td>
</tr>
</table>
<pre>
## Reproduction
[20.1.0 (works)](<https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:13,endLineNumber:11,positionColumn:13,positionLineNumber:11,selectionStartColumn:13,selectionStartLineNumber:11,startColumn:13,startLineNumber:11),source:'%23include+%3Cvector%3E%0A%23include+%3Cranges%3E%0A%23include+%3Ciostream%3E%0A%0A///+@remark+poor+person!'s+flatmap%0Ainline+constexpr+auto+flat_map+%3D+%5B%5D(+auto+%26%26func+)%0A%7B%0A++++return+std::views::transform(+std::forward%3Cdecltype(+func+)%3E(+func+)+)+%7C+std::views::join%3B%0A%7D%3B%0A%0Aint+main()+%7B%0A++++auto+res+%3D+std::vector%7B+1,+2,+3+%7D%0A+++++++++++++++++++%7C+flat_map(+%5B%5D(+const+int+i+)+-%3E+auto+%7B+return+std::vector%7Bi,+i+*+2+%7D%3B+%7D+)%0A+++++++++++++++++++%7C+std::ranges::to%3Cstd::vector%3E()%3B%0A+++++++++++++++++++%0A++++for+(int+i+:+res)+%7B%0A++++++++std::cout+%3C%3C+i+%3C%3C+!'+!'%3B%0A++++%7D%0A++++return+0%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),header:(),k:51.06906906906907,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang2010,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-std%3Dc%2B%2B23',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+20.1.0+(Editor+%231)',t:'0'),(h:output,i:(compilerName:'x86-64+gcc+14.2',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+20.1.0+(Compiler+%231)',t:'0')),header:(),k:48.93093093093094,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4>)
[trunk (fails)](<https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:24,endLineNumber:16,positionColumn:24,positionLineNumber:16,selectionStartColumn:24,selectionStartLineNumber:16,startColumn:24,startLineNumber:16),source:'%23include+%3Cvector%3E%0A%23include+%3Cranges%3E%0A%23include+%3Ciostream%3E%0A%0A///+@remark+poor+person!'s+flatmap%0Ainline+constexpr+auto+flat_map+%3D+%5B%5D(+auto+%26%26func+)%0A%7B%0A++++return+std::views::transform(+std::forward%3Cdecltype(+func+)%3E(+func+)+)+%7C+std::views::join%3B%0A%7D%3B%0A%0Aint+main()+%7B%0A++++auto+res+%3D+std::vector%7B+1,+2,+3+%7D%0A+++++++++++++++++++%7C+flat_map(+%5B%5D(+const+int+i+)+-%3E+auto+%7B+return+std::vector%7Bi,+i+*+2+%7D%3B+%7D+)%0A+++++++++++++++++++%7C+std::ranges::to%3Cstd::vector%3E()%3B%0A+++++++++++++++++++%0A++++for+(int+i+:+res)+%7B%0A++++++++std::cout+%3C%3C+i+%3C%3C+!'+!'%3B%0A++++%7D%0A++++return+0%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),header:(),k:51.06906906906907,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-std%3Dc%2B%2B23',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(trunk)+(Editor+%231)',t:'0'),(h:output,i:(compilerName:'x86-64+gcc+14.2',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(trunk)+(Compiler+%231)',t:'0')),header:(),k:48.93093093093094,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4>)
also fails to build on ubuntu clang++ 20.1.6
## Error log
```
In file included from <source>:2:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/ranges:45:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/iterator:68:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/streambuf_iterator.h:37:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/streambuf:45:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/ios_base.h:43:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/locale_classes.h:42:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/string:57:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.tcc:633:12: error: variable has incomplete type 'void'
633 | auto __r = std::move(__op)(__p + 0, __n + 0);
| ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.tcc:607:7: note: in instantiation of function template specialization 'std::basic_string<wchar_t>::resize_and_overwrite<(lambda at /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.h:4832:9) &>' requested here
607 | { resize_and_overwrite<_Operation&>(__n, __op); }
| ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.h:4831:7: note: in instantiation of function template specialization 'std::basic_string<wchar_t>::__resize_and_overwrite<(lambda at /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.h:4832:9)>' requested here
4831 | __ws.__resize_and_overwrite(__s.size(),
| ^
1 error generated.
ASM generation compiler returned: 1
In file included from <source>:2:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/ranges:45:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/iterator:68:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/streambuf_iterator.h:37:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/streambuf:45:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/ios_base.h:43:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/locale_classes.h:42:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/string:57:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.tcc:633:12: error: variable has incomplete type 'void'
633 | auto __r = std::move(__op)(__p + 0, __n + 0);
| ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.tcc:607:7: note: in instantiation of function template specialization 'std::basic_string<wchar_t>::resize_and_overwrite<(lambda at /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.h:4832:9) &>' requested here
607 | { resize_and_overwrite<_Operation&>(__n, __op); }
| ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.h:4831:7: note: in instantiation of function template specialization 'std::basic_string<wchar_t>::__resize_and_overwrite<(lambda at /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/basic_string.h:4832:9)>' requested here
4831 | __ws.__resize_and_overwrite(__s.size(),
| ^
1 error generated.
Execution build compiler returned: 1
Build failed
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsW1-Po7oV_zTOizURGAjwkIeQmUiV2rtVV-0rMmAS7xqb2iYzez99dWxCkhkye297Vc3uzYglwT62z__zO0mWGsP3krE1SgqUPC7oYA9Kr01NdRsEyaJSzbc1IhEiEf4H67VqhtpyJVGwgSspSLAMlwFGJHtW-qtBJEfJIyIZirYHa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