-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 C++ One Definition Rule violations and misc. UB #25394
Conversation
0eceafc
to
9a9bfd6
Compare
It should also be possible to use C++ |
GCC10 comes with the vagrant build. The build is still not passing even with these fixes because LTO isn't enabled. LTO can save size and increase performance by 10-20%. |
Two structs with the same name must have exactly the same definition, no matter where they occur in the program. Move each sample register struct definition into the associated class definition so they are in a different namespace and no longer identicially named, thus fixing this issue.
Allows update of CAN interface during driver initialization without UB-inducing casting away of const.
Switch to const extern hal reference, then use mutability of can array to store the CAN driver reference during driver init and eliminate UB.
Eliminates UB, now possible with mutable can array in AP_HAL.
Eliminates UB, now possible with mutable can array in AP_HAL.
Avoids UB-inducing assumption that UART drivers are consecutive in the serial() function.
9a9bfd6
to
8e4070d
Compare
Feedback is to split this up.
|
Fix various violations of the C++ One Definition Rule discovered during testing with LTO.
Fix a couple of easy UB cases noticed when doing the above.
Not necessarily an exhaustive list, but this does fix the complete list of violations diagnosed by GCC.
No code size or functional change.