-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Rearrange initialiser lists so we can use -Werror=reorder #28165
Rearrange initialiser lists so we can use -Werror=reorder #28165
Conversation
4ec144c
to
35b08c2
Compare
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 looked through all of these and nothing raises immediate concern that an initialization order was wrong.
I agree that we can remove blah()
in most cases as in the member initializer list that is identical in behavior to T blah;
in the class definition so long as T
is a class type. If T
is not, then we need to keep it.
35b08c2
to
d7b95a7
Compare
-Werror=reorder enforces a rule that initalisers must appear in the same order as the members they are initialising appear in the class declaration.
Having these appear in the wrong order can lead to programmers believing one thing about the order of object construction when something else is happening.
See point 3 from: https://en.cppreference.com/w/cpp/language/constructor
These patches are pulled out of a larger PR as they are completely no-compiler-output-change: