What is exactly an "invalid conversion specification"?

Viewed 3242

As per C11, chapter §7.21.6.1, P9

If a conversion specification is invalid, the behavior is undefined.282) If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.

Till time, my understanding was, for

  char str [] = "Sourav";
  • A statement like printf("%S", str); belong to the first sentence, there exist no CS as %S (UPPERCASE)
  • A statement like printf("%d", str); belongs to the second sentence (mismatch between CS and argument type, but the %d is not an "invalid" CS, anyway)

until advised otherwise by a recent comment thread.

Is my understanding wrong? Can the second statement also be categorized as "invalid" (PS- not "wrong") conversion specifier?


Update: The answer and the comment thread is deleted, here's a snap for <10K users.

3 Answers
Related