https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82304
--- Comment #3 from CVS Commits ---
The master branch has been updated by Jakub Jelinek :
https://gcc.gnu.org/g:eeb54a14c48f543857f561556ab1fc49dc21af26
commit r11-893-geeb54a14c48f543857f561556ab1fc49dc21af26
Author: Jakub Jelinek
Date: Thu Jun 4 09:09:01 2020 +0200
c++: Reject some further reinterpret casts in constexpr [PR82304, PR95307]
cxx_eval_outermost_constant_expr had a check for reinterpret_casts from
pointers (well, it checked from ADDR_EXPRs) to integral type, but that
only caught such cases at the toplevel of expressions.
As the comment said, it should be done even inside of the expressions,
but at the point of the writing e.g. pointer differences used to be a
problem. We now have POINTER_DIFF_EXPR, so this is no longer an issue.
Had to do it just for CONVERT_EXPR, because the FE emits NOP_EXPR casts
from pointers to integrals in various spots, e.g. for the PMR & 1 tests,
though on NOP_EXPR we have the REINTERPRET_CAST_P bit that we do check,
while on CONVERT_EXPR we don't.
2020-06-04 Jakub Jelinek
PR c++/82304
PR c++/95307
* constexpr.c (cxx_eval_constant_expression): Diagnose CONVERT_EXPR
conversions from pointer types to arithmetic types here...
(cxx_eval_outermost_constant_expr): ... instead of here.
* g++.dg/template/pr79650.C: Expect different diagnostics and
expect
it on all lines that do pointer to integer casts.
* g++.dg/cpp1y/constexpr-shift1.C: Expect different diagnostics.
* g++.dg/cpp1y/constexpr-82304.C: New test.
* g++.dg/cpp0x/constexpr-95307.C: New test.