public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111493] New: [concepts] multidimensional subscript operator inside requires is broken
@ 2023-09-20  7:38 elrodc at gmail dot com
  2023-09-20 12:45 ` [Bug c++/111493] " ppalka at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: elrodc at gmail dot com @ 2023-09-20  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111493
           Summary: [concepts] multidimensional subscript operator inside
                    requires is broken
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: elrodc at gmail dot com
  Target Milestone: ---

Two example programs:

>  #include <concepts>
>  constexpr auto foo(const auto &A, int i, int j)  requires(requires(decltype(A) a, int ii) { a[ii, ii]; }) {
>    return A[i, j];
>  }
>  constexpr auto foo(const auto &A, int i, int j) {
>    return A + i + j;
>  }
>  static_assert(foo(2,3,4) == 9);


>  #include <concepts>
>  template <typename T, typename S>
>  concept CartesianIndexable = requires(T t, int i) {
>    { t[i, i] } -> std::convertible_to<S>;
>  };
>  static_assert(!CartesianIndexable<double,int>);

These result in errors of the form

  error: invalid types 'const int[int]' for array subscript

Here is godbolt for reference: https://godbolt.org/z/WE66nY8zG

The invalid subscript should result in the `requires` failing, not an error.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-24 18:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20  7:38 [Bug c++/111493] New: [concepts] multidimensional subscript operator inside requires is broken elrodc at gmail dot com
2023-09-20 12:45 ` [Bug c++/111493] " ppalka at gcc dot gnu.org
2023-09-20 17:50 ` elrodc at gmail dot com
2023-09-22 10:31 ` cvs-commit at gcc dot gnu.org
2023-09-24 18:42 ` cvs-commit at gcc dot gnu.org
2023-09-24 18:52 ` ppalka at gcc dot gnu.org
2023-09-24 18:52 ` ppalka at gcc dot gnu.org

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).