Skip to content

C-style String Formatting Should Be Eliminated or Checked #1376

Open
@andrew-lunarg

Description

@andrew-lunarg

We use printf compatible formatting in error logging, where the formatting statements are rarely executed and so errors can hide.
Something in our implementation means compilers don't do the error checking they are able to do for printf.
For example, this compiles without warning:

GFXRECON_LOG_DEBUG("Attempt to reset current file to itself: %p.", 0.3784747f);

By contrast, this generates a warning that is upgraded to an error:

printf("Attempt to reset current file to itself: %p.", 0.3784747f);
OutPut:
warning C4477: 'printf' : format string '%p' requires an argument of type 'void *', but variadic argument 1 has type 'double'

(interestingly the float is reported as a double)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions