From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 963D4385480D; Thu, 24 Dec 2020 21:38:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 963D4385480D From: "aschepler at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98440] New: Accepts ill-formed reinterpret_cast(1) Date: Thu, 24 Dec 2020 21:38:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: aschepler at gmail dot com 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2020 21:38:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98440 Bug ID: 98440 Summary: Accepts ill-formed reinterpret_cast(1) Product: gcc Version: 10.2.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: aschepler at gmail dot com Target Milestone: --- g++ does not give any error or warning for a reinterpret_cast when the targ= et type is an rvalue reference type and the expression operand is a prvalue, f= or example reinterpret_cast(1). In standard section [expr.reinterpret.cast], casts to reference types are described only by paragraph 11, which allows casting a glvalue to a referen= ce type, but specifically says "No temporary is created". So the temporary materialization conversion can't be implicitly used like in most expression= s, and the paragraph can't apply. Clang++, MSVC, and ICC all produce error messages for the expression reinterpret_cast(1).=