2 ms·
No, this optimization also happens when you `#include <stdio.h>`. More accurately speaking, GCC (among others) evidently assumes that printf is the standard C l
by lifthrasiir 5y ago
No, this optimization also happens when you `#include <stdio.h>`. More accurately speaking, GCC (among others) evidently assumes that printf is the standard C library function no matter prototype is defined or not and replaces it with puts under the same assumption plus the following additional conditions:
- No other arguments are present.
- The format argument has no format specifiers and ends with `\n`.
- The return value is unused. (So `return printf("...\n");` would have prevented this optimization.)