Shouldn't this code generate C4473

James Bloom-Scheff 1 Reputation point
2022-06-29T17:26:57.007+00:00

This line of code isn't generating any errors:

sprintf(szErrFmtStr, "Failed to connect to %s");

shouldn't this generate C4473 - not enough arguments passed for format string

Or am I missing something? The code compiles without warnings, but gives an access violation when executed. It doesn't look like the warning is disabled.

I'm compiling with VS2019, warning level set to 4.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,441 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
2,633 questions
{count} votes

1 answer

Sort by: Most helpful
  1. James Bloom-Scheff 1 Reputation point
    2022-06-29T19:02:51.15+00:00

    Well, I found this

    define sprintf libintl_sprintf

    so its not sprintf being called but libintl_sprintf. I imagine that means the compile doesn't know to check the arguments.

    That was it

    No comments