Skip to content

The -Wconversion warning in the Compiler Options Hardening Guide should come with a caveat for brown-field projects #819

Open
@thomasnyman

Description

@thomasnyman

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:

Feel free to add your -Wconversion tips in the comments for this issue!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions