3 ms·
I’m going to look it up Monday, pretty sure there is something surprising in the printf impl, and IIRC there’s like no type safety at all. I vaguely remember wr
by dahart 7y ago
I’m going to look it up Monday, pretty sure there is something surprising in the printf impl, and IIRC there’s like no type safety at all. I vaguely remember writing buggy code that printed out data that I didn’t pass to printf.
- boulos 7y agoThat’s common though for variadic functions, particularly printf! Many printf implementations will blindly do a va_arg (popping the stack pointer by 4 or 8 bytes) if the format string says so. If your call to printf looks like: printf(“%d %d %d %d”, x, y); then you’re going to “read” two more ints from the stack at the call site. clang (and later gcc, I think) thus have a semantic analysis pass that understands/parses printf-style formatting strings so it can tell “hey, you didn’t pass enough arguments” or just as frequently “you passed too few”.