To support my understanding (and probably to reasonify the understanding in first place), let me add my two cents.
For a minute, see footnote 282 as indicated in the quote. It says:
See "Future Directions of the Library (7.31.11).
and in §7.31.11
Lowercase letters can be added to conversion specifiers and length modifiers in fprintf and fscanf . Other characters may be used in extensions.
Which does not mention the relationship between CS and its argument (if any). Thus, the "validity" of the CS is independent of the argument.
Now saying a couple more pointers
Point 1: pay attention to the mention of the phrase "conversion specification", not the conversion specifier in the quote. According to the chapter of §7.21.6.1 / P4,
Each conversion specification is entered with a % character. After % follows the following appear in sequence:
Zero or more flags [...]
Additional minimum field width [...]
Optional accuracy [...]
Additional length modifier [...]
Conversion specifier character [...]
and we have final listings for all the items mentioned in
- P5, field width and accuracy
- P6 flags
- P7 length modifier
- P8, conversion specifier
Thus, there is a connection (or should be) with the argument provided to determine the "validity" of the conversion specification.
In addition to this understanding, borrowing words from the commentary of Ajay Brahmaksatriya
“I think the current word here is“ consistent. ”The first sentence says that if there is a qualifier in the string that is not valid. If not, then each qualifier is matched with the corresponding argument. Then the second statement says the type match ..... I think the second example does not belong to the first category, because "the corresponding" is not used "
Point 2 :: . On the other hand, the specification is quite distinctly different from the “mismatch” between the CS and the corresponding argument type provided. So this is a completely different case.
Now, for example, in the case where both cases are combined, it is difficult to say which condition causes the UB, but it is UB, for several reasons.
Example:
printf("%D", str);
after the question.
Sourav ghosh
source share