Fix regression because of adding copy constructor #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The change to add a copy constructor from SafeInt to SafeInt caused a regression in some versions of gcc. See MoveRegression() in CompileTest.cpp. It's not clear just why adding a copy constructor might cause this problem, particularly only in some compilers.
The problem came in when running clang with -Wall -Wextra, which caused warnings about a user-supplied assignment operator which didn't have a matching copy constructor. Adding a copy constructor seemed like the right approach, but it caused this regression.
In addition, adding a move constructor and move assignment operator was also tried, and it didn't help. In order to avoid the problem, it seems that none of:
copy constructor
move constructor
assignement operator
move assignment operator
can exist. It's fine that they don't exist, the defaults for all of these do the right thing. In addition, declaring these operators as = default also resulted in errors.
In addition, while clang was building with std=c++17, gcc was not. That's been corrected to ensure the regression test actually works (and general goodness, tests should be equivalent).