public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/110139] [13/14 Regression] Ambiguous use of [] operator for 0-sized arrays (with clang)
Date: Tue, 06 Jun 2023 10:30:45 +0000	[thread overview]
Message-ID: <bug-110139-4-lkl7S3nmDO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110139-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC gives an error for the original testcase with -pedantic

In file included from arr.cc:1:
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array: In instantiation of
'constexpr std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::front()
[with _Tp = int; unsigned int _Nm = 0; reference = int&]':
arr.cc:2:21:   required from here
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array:243:24: error: ambiguous
overload for 'operator[]' (operand types are 'std::__array_traits<int,
0>::_Type' and 'int')
  243 |         return _M_elems[0];
      |                ~~~~~~~~^
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array:243:24: note: candidate:
'operator[](int*, int)' (built-in)
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array:68:13: note: candidate: '_Tp&
std::__array_traits<_Tp, 0>::_Type::operator[](std::size_t) const [with _Tp =
int; std::size_t = unsigned int]'
   68 |        _Tp& operator[](size_t) const noexcept { __builtin_trap(); }
      |             ^~~~~~~~
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array: In instantiation of
'constexpr const std::array<_Tp, _Nm>::value_type& std::array<_Tp,
_Nm>::front() const [with _Tp = int; unsigned int _Nm = 0; const_reference =
const int&]':
arr.cc:2:21:   required from here
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array:253:24: error: ambiguous
overload for 'operator[]' (operand types are 'const std::__array_traits<int,
0>::_Type' and 'int')
  253 |         return _M_elems[0];
      |                ~~~~~~~~^
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array:253:24: note: candidate:
'operator[](int*, int)' (built-in)
/home/jwakely/gcc/13.1.0/include/c++/13.1.0/array:68:13: note: candidate: '_Tp&
std::__array_traits<_Tp, 0>::_Type::operator[](std::size_t) const [with _Tp =
int; std::size_t = unsigned int]'
   68 |        _Tp& operator[](size_t) const noexcept { __builtin_trap(); }
      |             ^~~~~~~~

  parent reply	other threads:[~2023-06-06 10:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06  9:18 [Bug libstdc++/110139] New: [libstdc++] " joseph.faulls at imgtec dot com
2023-06-06  9:18 ` [Bug libstdc++/110139] " joseph.faulls at imgtec dot com
2023-06-06 10:26 ` [Bug libstdc++/110139] [13/14 Regression] " redi at gcc dot gnu.org
2023-06-06 10:30 ` redi at gcc dot gnu.org [this message]
2023-06-06 10:44 ` joseph.faulls at imgtec dot com
2023-06-06 11:02 ` redi at gcc dot gnu.org
2023-06-06 11:02 ` redi at gcc dot gnu.org
2023-06-06 11:45 ` cvs-commit at gcc dot gnu.org
2023-06-06 13:34 ` cvs-commit at gcc dot gnu.org
2023-06-06 13:34 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-110139-4-lkl7S3nmDO@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).