From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C12E5395A419; Wed, 16 Nov 2022 13:44:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C12E5395A419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668606293; bh=NVsolbGWlDe0SJq5yXmpO0wZVwOla00iv+xFiAwJ0u8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KYaTZ/KcTfDWo+AzwNecgpJ6B8D82y526mv1rOfWmRTL4IiOIxOHAhkZ0JKRzBXLs x73yTvz0bA60AM3ec5Glnj83d53iWRUtjNgHVfDbYm+Id4AWQUqqF3WVHL7oMaMj+r Ki7YyrpYznnX3EOU5lchPUtlKH/lvgaLTUPc0HHU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107624] [c++23] Wrong code with static operator () Date: Wed, 16 Nov 2022 13:44:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107624 --- Comment #2 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:cf958f8f168f695d49e29297ef9fb37f6efa5d0f commit r13-4095-gcf958f8f168f695d49e29297ef9fb37f6efa5d0f Author: Jakub Jelinek Date: Wed Nov 16 14:42:54 2022 +0100 c++: Fix up calls to static operator() or operator[] [PR107624] 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 funct= ion operator. On Mon, Nov 14, 2022 at 06:29:44PM -0500, Jason Merrill wrote: > Indeed. The code in build_new_method_call for this case has the comm= ent > > /* In an expression of the form `a->f()' where `f' turns > out to be a static member function, `a' is > none-the-less evaluated. */ Had to tweak 3 spots for this. Furthermore, found that if in non-pedan= tic C++20 compilation static operator[] is accepted, we required that it ha= s 2 arguments, I think it is better to require exactly one because that case is the only one that will actually work in C++20 and older. 2022-11-16 Jakub Jelinek PR c++/107624 * call.cc (keep_unused_object_arg): New function. (build_op_call): Use it. (build_op_subscript): Likewise. (build_new_op): Similarly for ARRAY_REF. (build_new_method_call): Use it. * decl.cc (grok_op_properties): For C++20 and earlier, if operator[] is static member function, require exactly one parameter rather than exactly two parameters. * g++.dg/cpp23/static-operator-call4.C: New test. * g++.dg/cpp23/subscript10.C: New test. * g++.dg/cpp23/subscript11.C: New test.=