[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 --- Comment #9 from Martin Sebor --- The purpose of friendship is to grant access to class members that would otherwise be inaccessible. The purpose of constructors is to establish class invariants, and it is the responsibility of member

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread redbeard0531 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 --- Comment #8 from Mathias Stearn --- > If the constructor had other side-effects (e.g., count > the number of objects of the class) bypassing it could > violate the invariant. I thought one of the points of friendship was to allow friends

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 Martin Sebor changed: What|Removed |Added Status|NEW |RESOLVED Resolution|---

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 Richard Biener changed: What|Removed |Added Status|WAITING |NEW --- Comment #6 from Richard Biener

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 --- Comment #5 from Jonathan Wakely --- IMHO classes and their friends should not have any special exemptions, because undefined behaviour is still undefined behaviour, it doesn't matter who does it. But in this case I don't think there is any

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 --- Comment #4 from Jonathan Wakely --- The Position type is trivially-copyable, so IMHO shouldn't warn about uses of memset/memcpy, but I'm not sure what the conditions for the warning are.

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 --- Comment #3 from Richard Biener --- Note for the example if you use -O3 the loop gets turned into memset() and the code generated is the same besides the memset being conditional on if (_buckets != 0) For the diagnostic, isn't class Position

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-08 Thread redbeard0531 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 --- Comment #2 from Mathias Stearn --- Here is a boiled down example of some of our code that trips this warning: https://godbolt.org/g/ChLrch. It also shows why we do this, since the codegen is *substantially* better for init_table_memset than

[Bug c++/85707] -Wclass-memaccess should excempt safe usage inside of a class and its friends

2018-05-08 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85707 Martin Sebor changed: What|Removed |Added Keywords||diagnostic