Does this invoke undefined behaviour?
问题 Consider the following C program: #include <stdio.h> int main(){ int a =-1; unsigned b=-1; if(a==b) printf("%d %d",a,b); else printf("Unequal"); return 0; } In the line printf("%d %d",a,b); , "%d" is used to print an unsigned type. Does this invoke undefined behavior and why? 回答1: Although you are explicitly allowed to use the va_arg macro from <stdarg.h> to retrieve a parameter that was passed as an unsigned as an int (7.15.1.1/2), in the documentation for fprintf (7.19.6.1/9) which also