[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

Maryam Moghadas via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 24 08:14:10 PDT 2025


maryammo wrote:

Building Clang with libc++ and using it, the following test asserts with this patch: (Ubuntu)

```
#include <ostream>
#include <syncstream>

#define NS std::basic_ostream<char, std::char_traits<char>>
#define WS std::basic_ostream<wchar_t, std::char_traits<wchar_t>>

#include <type_traits>

NS& g00 (NS&& a0, const char& a1) {
    static_assert(
       std::is_same_v<NS&&,
         decltype(std::operator<< <NS, char>(std::move(a0), a1))>,
      "Unexpected return type");
}
```

```
$clang++ reg1.C -stdlib=libc++ -nostdinc++ -I/path-to-build/include/c++/v1/ -I/path-to-build/include/powerpc64le-unknown-linux-gnu/c++/v1/  -c

string_view:305:17: error: static assertion failed due to requirement 'is_standard_layout<std::ostream>::value': Character type of basic_string_view must be standard-layout
  305 |   static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
reg1.C:12:61: note: in instantiation of template class 'std::basic_string_view<std::ostream, char>' requested here
   12 |          decltype(std::operator<< <NS, char>(std::move(a0), a1))>,
      |                                                             ^
reg1.C:12:19: note: while substituting deduced template arguments into function template 'operator<<' [with _CharT = std::basic_ostream<char, std::char_traits<char>>, _Traits = char]
   12 |          decltype(std::operator<< <NS, char>(std::move(a0), a1))>,
      |                   ^
1 error generated.
```

@zyn0217 Could you please take a look? Thanks. 

https://github.com/llvm/llvm-project/pull/122423


More information about the cfe-commits mailing list