[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 21 22:50:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's completely logical.
using const_int = const int;
const int* p = new const_int();
Do you expect to never be able to delete this object, instead being forced to
leak it?
What about:
void f() { const int i = 0; }
Do you think this stack variable can't be destroyed, because it's const?
The const qualifier affects modification of the object, not its destruction.
Your mental model of C++ is simply not how the language works.
More information about the Gcc-bugs
mailing list