public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/85087] call to a non-const member function on a const lvalue accepted
[not found] <bug-85087-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-02 4:39 ` pinskia at gcc dot gnu.org
2021-08-06 9:33 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-02 4:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85087
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2018-03-28 00:00:00 |2021-8-1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang, gcc, and msvc all accepts this
ICC rejects this.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/85087] call to a non-const member function on a const lvalue accepted
[not found] <bug-85087-4@http.gcc.gnu.org/bugzilla/>
2021-08-02 4:39 ` [Bug c++/85087] call to a non-const member function on a const lvalue accepted pinskia at gcc dot gnu.org
@ 2021-08-06 9:33 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-06 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85087
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #0)
> While looking at bug 85043 I noticed that in the test case below, GCC
> correctly rejects the attempt to convert the const reference to B to A in
> the call to g()
No, it allows the conversion, but that produces an rvalue which can't bind to
the A& parameter of g.
> but it accepts the same invalid conversion in the context
> where a a non-const member function on the result of the conversion is
> called. Other compilers reject both conversions.
Why should it be rejected? ((A)b) calls the conversion operator to get a const
A& and then initializes an rvalue of type A from that. The rvalue is not const,
and you can call the member function.
i.e. equivalent to:
static_cast<A>(b.operator const A&()).f();
or:
A(b).f();
both of which are accepted, as they should be.
EDG accepts the static_cast<A> version, but not A(b).f(), I don't know why. But
I think EDG has the bug here, not GCC.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-06 9:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-85087-4@http.gcc.gnu.org/bugzilla/>
2021-08-02 4:39 ` [Bug c++/85087] call to a non-const member function on a const lvalue accepted pinskia at gcc dot gnu.org
2021-08-06 9:33 ` 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).