public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/68888] No Warning when converting an array of a subclass to its parent
       [not found] <bug-68888-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-10  2:30 ` pinskia at gcc dot gnu.org
  2021-08-10 10:25 ` redi at gcc dot gnu.org
  2021-10-27  5:14 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-10  2:30 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/68888] No Warning when converting an array of a subclass to its parent
       [not found] <bug-68888-4@http.gcc.gnu.org/bugzilla/>
  2021-08-10  2:30 ` [Bug c++/68888] No Warning when converting an array of a subclass to its parent pinskia at gcc dot gnu.org
@ 2021-08-10 10:25 ` redi at gcc dot gnu.org
  2021-10-27  5:14 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-10 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-08-10
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is undefined behaviour, and should definitely warn (and UBsan should give
an error too).

The implicit conversion sequence of array-to-pointer decay followed by
derived-to-base conversion should warn. If the derived-to-base conversion is
really desired (because no pointer arithmetic will be done on the result) then
users can get a pointer to the first element of the array explicitly, so there
is no implicit decay e.g. any of these would not warn:

  go(&bs[0]);
  go(&*bs);
  go((B*)bs);
  go(std::begin(bs));

(of course the code would still have undefined behaviour due to the arithmetic
in go, but it wouldn't warn because there's no implicit decay).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/68888] No Warning when converting an array of a subclass to its parent
       [not found] <bug-68888-4@http.gcc.gnu.org/bugzilla/>
  2021-08-10  2:30 ` [Bug c++/68888] No Warning when converting an array of a subclass to its parent pinskia at gcc dot gnu.org
  2021-08-10 10:25 ` redi at gcc dot gnu.org
@ 2021-10-27  5:14 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-10-27  5:14 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
Any ideas for a proposed name for the flag that would control this warning?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-27  5:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-68888-4@http.gcc.gnu.org/bugzilla/>
2021-08-10  2:30 ` [Bug c++/68888] No Warning when converting an array of a subclass to its parent pinskia at gcc dot gnu.org
2021-08-10 10:25 ` redi at gcc dot gnu.org
2021-10-27  5:14 ` egallager 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).