[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-22 Thread msharov at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #12 from Mike Sharov --- (In reply to Jonathan Wakely from comment #10) > It's simply not how C++ works. Quite right. I already agreed with you here; we are arguing about whether it /should/ work this way :) > An object's lifetime i

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-22 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #11 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #10) > (In reply to Mike Sharov from comment #8) > > My mental model here is actually of const correctness, not C++ specifically. > > When I pass around a const ob

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-22 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #10 from Jonathan Wakely --- (In reply to Mike Sharov from comment #8) > My mental model here is actually of const correctness, not C++ specifically. > When I pass around a const object I expect it to stay unmodified. Consider a > fun

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-22 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #9 from Jonathan Wakely --- That's not how C++ works.

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread msharov at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #8 from Mike Sharov --- (In reply to Jonathan Wakely from comment #7) > Your mental model of C++ is simply not how the language works. My mental model here is actually of const correctness, not C++ specifically. When I pass around a

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 Jonathan Wakely changed: What|Removed |Added Status|WAITING |RESOLVED Resolution|---

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread msharov at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #6 from Mike Sharov --- (In reply to Jonathan Wakely from comment #5) > Nope, see the C++ standard: > > [ Note: A pointer to a const type can be the operand of a > delete-expression; Ok, I guess; you have to follow the standard, a

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #5 from Jonathan Wakely --- Nope, see the C++ standard: [ Note: A pointer to a const type can be the operand of a delete-expression; it is not necessary to cast away the constness (8.5.1.11) of the pointer expression before it

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread msharov at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #4 from Mike Sharov --- (In reply to Jonathan Wakely from comment #3) > Nothing stops you deallocating a const pointer. According to http://en.cppreference.com/w/cpp/memory/new/operator_delete The delete operator takes a void* and at

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed|

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #3 from Jonathan Wakely --- (In reply to Mike Sharov from comment #2) > (In reply to Jonathan Wakely from comment #1) > > (In reply to Mike Sharov from comment #0) > > > When the pointer is const, it can not point to owned memory > >

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread msharov at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #2 from Mike Sharov --- (In reply to Jonathan Wakely from comment #1) > (In reply to Mike Sharov from comment #0) > > When the pointer is const, it can not point to owned memory > Why not? Because a const pointer can not be freed. By

[Bug c++/85858] -Weffc++ should not require copy ctor for const pointers

2018-05-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85858 --- Comment #1 from Jonathan Wakely --- (In reply to Mike Sharov from comment #0) > When the pointer is const, it can not point to owned memory Why not?