From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 11B78385DC00; Thu, 4 Jan 2024 08:17:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11B78385DC00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704356226; bh=zHOiEUT2kywaXdW9c7CXJbB90JdqMqO+CMT8zyvLvng=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B6L/lQWpOmcuy6D+7avQtacSMT49t5pRQWg+tHnImBKenUncecIQTMe+0dd0e5ToV c9xwWIA266OAnt8pp8GSIwxlgP4Dcaz6VYM4sNh7qb9/UI0J2I7o1i/cCD84RI8mHv 08K930RL0QccLPECSatEaMgeblFQfYnfn+PXBNKU= From: "m.cencora at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113219] Overloaded ref-qualified conversion operator triggers bogus -Wconversion Date: Thu, 04 Jan 2024 08:17:04 +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: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: m.cencora at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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=3D113219 --- Comment #2 from m.cencora at gmail dot com --- So I guess this falls into the "confusing overload resolution for user-defi= ned conversion" but I fail to see what can be confusing here. createInt() returns prvalue, so later it binds to xvalue for the purpose of implicit conversion operator invocation. That means that r-value qualified conversion operator is chosen. If your advice is to avoid using "-Wconversion" that it is rather unfortuna= te because user looses good warnings (e.g. about conversions that may alter the value). Also there is no way to silence the warning for such a code, since gcc warn= s on each call-site, not on definition-site of the overloads. So it either unfeasible or even impossible if the definitions are in library code, but warnings are enabled in user code. Please consider removing the warning generation in such scenarios.=