public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/82304] GCC compiles constexpr function with double reinterpret_cast in a constant context
       [not found] <bug-82304-4@http.gcc.gnu.org/bugzilla/>
@ 2020-06-04  7:09 ` cvs-commit at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-04  7:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82304

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:eeb54a14c48f543857f561556ab1fc49dc21af26

commit r11-893-geeb54a14c48f543857f561556ab1fc49dc21af26
Author: Jakub Jelinek <jakub@redhat.com>
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  <jakub@redhat.com>

            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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-04  7:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-82304-4@http.gcc.gnu.org/bugzilla/>
2020-06-04  7:09 ` [Bug c++/82304] GCC compiles constexpr function with double reinterpret_cast in a constant context cvs-commit 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).