public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113388] New: Calling explicit object member function without object argument inside a function that is not an implicit object member function
@ 2024-01-14 16:51 cooky.ykooc922 at gmail dot com
2024-01-15 7:04 ` [Bug c++/113388] " waffl3x at protonmail dot com
2024-01-15 10:18 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: cooky.ykooc922 at gmail dot com @ 2024-01-14 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113388
Bug ID: 113388
Summary: Calling explicit object member function without object
argument inside a function that is not an implicit
object member function
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cooky.ykooc922 at gmail dot com
Target Milestone: ---
According to https://eel.is/c++draft/over.call.func#3:
In unqualified function calls, the function is named by a primary-expression.
The function declarations found by name lookup ([basic.lookup]) constitute the
set of candidate functions. Because of the rules for name lookup, the set of
candidate functions consists either entirely of non-member functions or
entirely of member functions of some class T. In the former case or if the
primary-expression is the address of an overload set, the argument list is the
same as the expression-list in the call. Otherwise, the argument list is the
expression-list in the call augmented by the addition of an implied object
argument as in a qualified function call. If the current class is, or is
derived from, T, and the keyword this ([expr.prim.this]) refers to it, then the
implied object argument is (*this). Otherwise, a contrived object of type T
becomes the implied object argument; if overload resolution selects a
non-static member function, the call is ill-formed.
In other words, the code snippet below must produce an error because a call to
'bar()' inside the function 'foo', 'baz', or any function which is not an
implicit object member function itself, is ill-formed without the object
argument. There is no error inside implicit object member function 'qux'
because the implied object argument is '*this' unlike other explicit object
member functions.
struct A {
void bar(this A) {}
static void foo() {
// not ok: this should be error
// because the overload resolution
// picked a non-static member function
// without an object argument
bar();
// ok [error as expected]:
// bar(A{});
// ok [converted to function pointer]:
(&A::bar)(A{});
// ok [called with an object argument]:
A{}.bar();
}
void baz(this A self) {
// ok
self.bar();
// ok [error as expected]
// self.bar(self);
// ok [error as expected]
// bar(A{});
// not ok: this should be error
// because the overload resolution
// picked a non-static function
// without an object argument
// even inside the scope of the
// explicit object member function
bar();
// ok
A{}.bar();
}
void qux() {
// ok
bar();
// ok [error as expected]
// bar(*this);
}
};
godbolt link with -std=c++23: https://godbolt.org/z/89Msa7Gfj
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/113388] Calling explicit object member function without object argument inside a function that is not an implicit object member function
2024-01-14 16:51 [Bug c++/113388] New: Calling explicit object member function without object argument inside a function that is not an implicit object member function cooky.ykooc922 at gmail dot com
@ 2024-01-15 7:04 ` waffl3x at protonmail dot com
2024-01-15 10:18 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: waffl3x at protonmail dot com @ 2024-01-15 7:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113388
--- Comment #1 from waffl3x <waffl3x at protonmail dot com> ---
Yeah, looks like a bug. I won't be able to look at it as I am in the
process of moving but it seems like a similar one to PR113348.
Thanks for the report!
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/113388] Calling explicit object member function without object argument inside a function that is not an implicit object member function
2024-01-14 16:51 [Bug c++/113388] New: Calling explicit object member function without object argument inside a function that is not an implicit object member function cooky.ykooc922 at gmail dot com
2024-01-15 7:04 ` [Bug c++/113388] " waffl3x at protonmail dot com
@ 2024-01-15 10:18 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-15 10:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113388
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-01-15
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-15 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-14 16:51 [Bug c++/113388] New: Calling explicit object member function without object argument inside a function that is not an implicit object member function cooky.ykooc922 at gmail dot com
2024-01-15 7:04 ` [Bug c++/113388] " waffl3x at protonmail dot com
2024-01-15 10:18 ` redi 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).