Description
Raised during the discussion in the 2025-03-20 - C/C++ Compiler BP Guide call.
The guide currently recommends enabling implicit conversion warnings using -Wconversion
and -Wsign-conversion
. The -Wconversion
option, in particular, may be cumbersome for brown-field projects to enable as it tends to generate a large number of false positives due to the implicit conversions being very common in C. This is explicitly called out in the GCC wiki page describing the -Wconversion
feature also noting that "[-Wconversion
] is designed for a niche of uses [such as security audits] where the programmer is willing to accept and workaround invalid warnings."
This type of caveat should be stated in a When not to use? or Additional Considerations section in the guide and encourage enabling -Wconversion
for green-field projects.
Nevetheless, big projects such as Chrome have explored enabling -Wconversion
. It would also be valuable to include practical advice for brown-field projects deploying -Wconversion
such as hints suggested in:
- https://genodians.org/nfeske/2021-12-07-wconversion
- https://stackoverflow.com/questions/59654423/how-to-fix-errors-caused-by-wconversion
- https://issues.chromium.org/issues/40457839
- https://community.memfault.com/t/the-best-and-worst-gcc-compiler-flags-for-embedded-interrupt/90/15
Feel free to add your -Wconversion
tips in the comments for this issue!