-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix deprecated copies and redundant moves #1950
Fix deprecated copies and redundant moves #1950
Conversation
Doesn't C++ automatically add these if they're not defined? I may be wrong though. |
Yes, but if you have deprecated copy warnings enabled they'll reported warnings. I'm trying to find a primary source, but per gcc's bugzilla, "The implicit definition of a copy constructor as defaulted is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared copy constructor or a user-declared destructor" TLDR: compile with -Wdeprecated-copy and observe compiler output |
Although this might be worth a larger discussion. What warnings does GTSAM currently compile with? Is there any interest in enabling more compiler warnings/enabling Werror? |
f7aecd8
to
846c29f
Compare
Okay I'm going to need your help understanding this better. I currently don't get these warnings so is it a result of a newer version of GCC? In general we ignore warnings since most of the time they don't reflect a real problem. I'm curious if suppressing these warnings are sufficient in your use case? My guiding philosophy here is less code is good code. |
Disagree. If we can -Wall so much the better!
Totally agree here, but I have a suspicion that this extra code might actually benefit performance even for other compilers? any idea, @mcm001 ? |
Hey! At least in some Godbolt testing, I don't see a meaningful difference in the actual binary output of this contrived test program with GCC 12.2 on x86 or arm64. I think this just comes down to if y'all are in favor of fixing warnings even if the code output is (probably) correct. I think that fixing rule-of-3/5/0-related warnings is a good idea, and deleting redundant moves also lets us write less code ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m in favor of -Wall so approving. We should probably add a gcc12 CI, maybe instead of gcc11. Not sure whether gcc9 is already EOL?
I've also got a tiny patchset that lets me build with -Wall -Wpedantic on GCC 12, should be ready here in a moment. Happy to add that in a follow-on PR, or add to this one |
And from https://gcc.gnu.org/gcc-9/ and https://gcc.gnu.org/gcc-10/ , it appears GCC 9/10 are EOL yeah |
Awesome ! Maybe do it in a follow-up PR where you also switch 11 to 12 in CI? |
Sounds good! Will add in a follow-on |
Fix deprecated copies and redundant moves
While working on wpilibsuite/allwpilib#7606 I had to disable deprecated copy and redundant move warnings. I'm not super great with this aspect of C++, but I've added default constructors where they were previously implicitly declared.