[Bug c++/68888] No Warning when converting an array of a subclass to its parent

2021-10-26 Thread egallager at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #2 from Eric Gallager  ---
Any ideas for a proposed name for the flag that would control this warning?

[Bug c++/68888] No Warning when converting an array of a subclass to its parent

2021-08-10 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Jonathan Wakely  changed:

   What|Removed |Added

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

--- Comment #1 from Jonathan Wakely  ---
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([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).

[Bug c++/68888] No Warning when converting an array of a subclass to its parent

2021-08-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||diagnostic
   Severity|normal  |enhancement