Skip to content

Improve cpp/wrong-type-format-argument by adding correct formatting specifier #15028

Open

Description

@AMS21

Description of the issue
Currently the cpp/wrong-type-format-argument diagnostic displays something like this

This argument should be of type 'int' but is of type 'unsigned long'.

It would be even more helpful if the diagnostic message would include the correct formatting specifier so it would look something like this:

This argument should be of type 'int' but is of type 'unsigned long'. Consider using '%ul' instead.

For reference cppreference has a great table about which specifier is needed for which type.

Activity

  1. MathiasVP commented on Dec 7, 2023

    @MathiasVP
    Contributor

    Hi @AMS21,

    That's a great suggestion. Thank you! I've recorded this in an internal issue 🙂.

  2. cooljeanius commented on Sep 22, 2024

    @cooljeanius

    The Copilot Autofix suggestions based on CodeQL code scanning alerts kinda provide for this, although they don't always match up with what the CodeQL diagnostic says itself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions