[Bug c++/98440] [9/10/11 Regression] Accepts ill-formed reinterpret_cast(1)

2021-04-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98440

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:07f56824fd4da14a48030e698c8eb58de951c741

commit r11-7994-g07f56824fd4da14a48030e698c8eb58de951c741
Author: Jason Merrill 
Date:   Mon Apr 5 15:50:48 2021 -0400

c++: reinterpret_cast from prvalue to rvalue ref [PR98440]

In r260622 I allowed this under the general principle that [basic.lval]
"Whenever a prvalue appears as an operand of an operator that expects a
glvalue for that operand, the temporary materialization conversion (7.3.4)
is applied to convert the expression to an xvalue."  But
[expr.reinterpret.cast] specifically excludes creating a temporary in this
case.

gcc/cp/ChangeLog:

PR c++/98440
* typeck.c (build_reinterpret_cast_1): Don't perform
temporary materialization.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/rv-cast6.C: Expect reinterpret_cast error.
* g++.dg/cpp0x/reinterpret_cast2.C: Adjust message.
* g++.old-deja/g++.jason/rvalue3.C: Likewise.

[Bug c++/98440] [9/10/11 Regression] Accepts ill-formed reinterpret_cast(1)

2021-04-05 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98440

Jason Merrill  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org
 Status|NEW |ASSIGNED

[Bug c++/98440] [9/10/11 Regression] Accepts ill-formed reinterpret_cast(1)

2021-01-14 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98440

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c++/98440] [9/10/11 Regression] Accepts ill-formed reinterpret_cast(1)

2020-12-27 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98440

Jonathan Wakely  changed:

   What|Removed |Added

  Known to fail||10.1.0, 11.0, 9.2.0
   Target Milestone|--- |9.4
Summary|Accepts ill-formed  |[9/10/11 Regression]
   |reinterpret_cast(1)  |Accepts ill-formed
   ||reinterpret_cast(1)
 CC||jason at gcc dot gnu.org
  Known to work||8.3.0

--- Comment #1 from Jonathan Wakely  ---
This was correctly rejected until r260622:

Fix cast to rvalue reference from prvalue.

* cvt.c (diagnose_ref_binding): Handle rvalue reference.
* rtti.c (build_dynamic_cast_1): Don't try to build a reference to
non-class type.  Handle xvalue argument.
* typeck.c (build_reinterpret_cast_1): Allow cast from prvalue to
rvalue reference.
* semantics.c (finish_compound_literal): Do direct-initialization,
not cast, to initialize a reference.