Pre-DR: variadic standard library functions =========================================== To what extent should the variadic functions in and be required to act as if they use the macros to access arguments? (The problem is well-known from comp.std.c, but there seems to be a lack of consensus on both the meaning and the intent of the standard. Furthermore, this issue is involved in one implementor's claims of nonconformance of other library implementations [1].) There are at least three cases involved: 1. Arguments of correct promoted type, and in range for unpromoted type, but not of the unpromoted type. #include void f(void) { // Suppose that unsigned char promotes to int. printf("%hhu", 0); } Here, %hhu expects an unsigned char, which has been promoted to int, but has been passed an int not derived from an unsigned char. Is this defined, or should it be? 2. Arguments of correct promoted type, but out of range for unpromoted type. #include void f(void) { // Suppose that UCHAR_MAX == 255. printf("%hhu", 256); } Here, the argument is of type int, the correct promoted type, but even printf implemented using the macros only can tell that it did not arise from an unsigned char. Is this defined, or should it be? If not, what purpose does the wording about printf converting the argument back to unsigned char before printing serve? (The disputes over conformance relate to failure to make such a conversion back to unsigned char.) 3. Arguments of incorrect type, allowed for va_arg by 7.15.1.1#2. #include void f(void) { printf("%x", 0); } Here, an int argument is passed where an unsigned int is expected, but the value is representable in both types. Is this defined, or should it be? [1] Some claims of nonconformance in this document are based on misunderstandings of the standard. In particular, all the claims of problems with implementing INTN_C macros by concatenation are wrong, as the parmaeter to such macros is specified as a "decimal, octal, or hexadecimal constant", not a general integer constant expression (and is unsuffixed by virtue of the syntax in 6.4.4.1, something missed in N1046). However, the question on what is defined for printf %hh is a genuine uncertainty about the standard.