https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115839

            Bug ID: 115839
           Summary: Some common patterns in libstdc++-14 break many
                    libraries with clang in C++23
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeanmichael.celerier at gmail dot com
  Target Milestone: ---

Issue also posted to the LLVM bugtracker:
https://github.com/llvm/llvm-project/issues/97842

Some repros ; easily reproducible on an archlinux container.

Ex. 1: https://github.com/boostorg/container/issues/282

Repro:

```bash
$ docker run -v $PWD:/src -it archlinux:latest
$ pacman -Sy
$ pacman -S clang 
$ echo '#include <boost/container/flat_map.hpp>

int main() {
  boost::container::flat_map<int, int> f;
  f[0];
}' > foo.cpp

$  clang++ foo.cpp -std=c++23 -I /src/boost_1_85_0
```

Ex. 2: https://github.com/martinus/unordered_dense/issues/119
Ex. 3: 
```c++
#include <nlohmann/json.hpp>

void x(const char* s, int n)
{
  nlohmann::json::parse(s, s + n);
}
```

cause errors such as : 

```
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:956:36:
error: no matching function for call to 'get'
  956 |             return
__convertible<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
      |                                           ^~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:955:11:
note: in instantiation of function template specialization 'std::tuple<const
std::basic_string<char> &>::__convertible_from_tuple_like()::(anonymous
class)::operator()<0UL>' requested here
  955 |           return []<size_t... _Is>(index_sequence<_Is...>) {
      |                  ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:1136:22:
note: in instantiation of function template specialization 'std::tuple<const
std::basic_string<char> &>::__convertible_from_tuple_like<const
std::basic_string<char> &>' requested here
 1136 |         constexpr explicit(!__convertible_from_tuple_like<_UTuple>())
      |                             ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_map.h:514:38:
note: while substituting deduced template arguments into function template
'tuple' [with _UTuple = const key_type &]
  514 |                                             std::tuple<const
key_type&>(__k),
      |                                                                        
^
/usr/include/nlohmann/detail/input/json_sax.hpp:442:66: note: in instantiation
of member function 'std::map<std::basic_string<char>, nlohmann::basic_json<>,
std::less<void>>::operator[]' requested here
  442 |             object_element =
&(ref_stack.back()->m_value.object->operator[](val) = discarded);
      |                                                                  ^
/usr/include/nlohmann/detail/input/parser.hpp:219:56: note: in instantiation of
member function
'nlohmann::detail::json_sax_dom_callback_parser<nlohmann::basic_json<>>::key'
requested here
  219 |                         if
(JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
      |                                                        ^
/usr/include/nlohmann/detail/input/parser.hpp:98:13: note: in instantiation of
function template specialization
'nlohmann::detail::parser<nlohmann::basic_json<>,
nlohmann::detail::iterator_input_adapter<const char
*>>::sax_parse_internal<nlohmann::detail::json_sax_dom_callback_parser<nlohmann::basic_json<>>>'
requested here
   98 |             sax_parse_internal(&sdp);
      |             ^
/usr/include/nlohmann/json.hpp:4029:113: note: in instantiation of member
function 'nlohmann::detail::parser<nlohmann::basic_json<>,
nlohmann::detail::iterator_input_adapter<const char *>>::parse' requested here
 4029 |         parser(detail::input_adapter(std::move(first),
std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result);
      |                                                                        
                                        ^
/usr/include/nlohmann/json.hpp:5138:28: note: in instantiation of function
template specialization 'nlohmann::basic_json<>::parse<const char *>' requested
here
 5138 |     return nlohmann::json::parse(s, s + n);
      |                            ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:122:5:
note: candidate template ignored: could not match 'tuple' against
'basic_string'
  122 |     get(tuple<_Elements...>& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:126:5:
note: candidate template ignored: could not match 'tuple' against
'basic_string'
  126 |     get(const tuple<_Elements...>& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:130:5:
note: candidate template ignored: could not match 'tuple' against
'basic_string'
  130 |     get(tuple<_Elements...>&& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:134:5:
note: candidate template ignored: could not match 'tuple' against
'basic_string'
  134 |     get(const tuple<_Elements...>&& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:138:5:
note: candidate template ignored: could not match 'array' against
'basic_string'
  138 |     get(array<_Tp, _Nm>&) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:142:5:
note: candidate template ignored: could not match 'array' against
'basic_string'
  142 |     get(array<_Tp, _Nm>&&) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:146:5:
note: candidate template ignored: could not match 'array' against
'basic_string'
  146 |     get(const array<_Tp, _Nm>&) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:150:5:
note: candidate template ignored: could not match 'array' against
'basic_string'
  150 |     get(const array<_Tp, _Nm>&&) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1250:5:
note: candidate template ignored: could not match 'pair' against 'basic_string'
 1250 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1255:5:
note: candidate template ignored: could not match 'pair' against 'basic_string'
 1255 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1260:5:
note: candidate template ignored: could not match 'pair' against 'basic_string'
 1260 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1265:5:
note: candidate template ignored: could not match 'pair' against 'basic_string'
 1265 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/ranges_util.h:444:5:
note: candidate template ignored: could not match 'subrange' against
'basic_string'
  444 |     get(const subrange<_It, _Sent, _Kind>& __r)
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/ranges_util.h:455:5:
note: candidate template ignored: could not match 'subrange' against
'basic_string'
  455 |     get(subrange<_It, _Sent, _Kind>&& __r)
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1272:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1272 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1277:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1277 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1282:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1282 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1287:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1287 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1292:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1292 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1297:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1297 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1302:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1302 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1307:5:
note: candidate template ignored: invalid explicitly-specified argument for
template parameter '_Tp'
 1307 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^
1 warning and 1 error generated.

```
  • [Bug libstdc++/115839] ... jeanmichael.celerier at gmail dot com via Gcc-bugs

Reply via email to