Bug 107684 - [C++23] P2589 - static operator[]
Summary: [C++23] P2589 - static operator[]
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 13.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: c++23-core
  Show dependency treegraph
 
Reported: 2022-11-14 18:22 UTC by Marek Polacek
Modified: 2022-11-28 22:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-11-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2022-11-14 18:22:54 UTC
See <https://wg21.link/p2589>.
Comment 2 Jakub Jelinek 2022-11-19 09:25:32 UTC
https://gcc.gnu.org/g:6492cec069bccf817ac5e984fb3eca407056a566

commit r13-4046-g6492cec069bccf817ac5e984fb3eca407056a566
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 15 08:00:21 2022 +0100

    c++: Implement C++23 P2589R1 - - static operator[]
    
    Here is a patch that implements the static operator[] paper.
    One thing that doesn't work properly is the same problem as I've filed
    yesterday for static operator() - PR107624 - that side-effects of
    the postfix-expression on which the call or subscript operator are
    applied are thrown away, I assume we have to add them into COMPOUND_EXPR
    somewhere after we find out that the we've chosen a static member function
    operator.
    
    2022-11-15  Jakub Jelinek  <jakub@redhat.com>
    
    gcc/c-family/
            * c-cppbuiltin.cc (c_cpp_builtins): Bump C++23
            __cpp_multidimensional_subscript macro value to 202211L.
    gcc/cp/
            * decl.cc (grok_op_properties): Implement C++23 P2589R1
            - static operator[].  Handle operator[] similarly to operator()
            - allow static member functions, but pedwarn on it for C++20 and
            older.  Unlike operator(), perform rest of checks on it though for
            C++20.
            * call.cc (add_operator_candidates): For operator[] with class
            typed first parameter, pass that parameter as first_arg and
            an adjusted arglist without that parameter.
    gcc/testsuite/
            * g++.dg/cpp23/subscript9.C: New test.
            * g++.dg/cpp23/feat-cxx2b.C: Expect a newer
            __cpp_multidimensional_subscript value.
            * g++.old-deja/g++.bugs/900210_10.C: Don't expect an error
            for C++23 or later.