public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aschepler at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/98440] New: Accepts ill-formed reinterpret_cast<int&&>(1)
Date: Thu, 24 Dec 2020 21:38:53 +0000	[thread overview]
Message-ID: <bug-98440-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98440
           Summary: Accepts ill-formed reinterpret_cast<int&&>(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 target
type is an rvalue reference type and the expression operand is a prvalue, for
example reinterpret_cast<int&&>(1).

In standard section [expr.reinterpret.cast], casts to reference types are
described only by paragraph 11, which allows casting a glvalue to a reference
type, but specifically says "No temporary is created". So the temporary
materialization conversion can't be implicitly used like in most expressions,
and the paragraph can't apply.

Clang++, MSVC, and ICC all produce error messages for the expression
reinterpret_cast<int&&>(1).

             reply	other threads:[~2020-12-24 21:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-24 21:38 aschepler at gmail dot com [this message]
2020-12-27 20:16 ` [Bug c++/98440] " redi at gcc dot gnu.org
2020-12-27 20:19 ` [Bug c++/98440] [9/10/11 Regression] " redi at gcc dot gnu.org
2021-01-14 11:14 ` rguenth at gcc dot gnu.org
2021-04-05 19:46 ` jason at gcc dot gnu.org
2021-04-05 21:27 ` cvs-commit at gcc dot gnu.org
2021-04-05 21:30 ` [Bug c++/98440] [9/10 " jason at gcc dot gnu.org
2021-06-01  8:19 ` rguenth at gcc dot gnu.org
2021-07-27 22:22 ` pinskia at gcc dot gnu.org
2022-05-27  9:44 ` [Bug c++/98440] [10 " rguenth at gcc dot gnu.org
2022-06-28 10:42 ` jakub at gcc dot gnu.org
2023-07-07  9:20 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-98440-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).