ISO C99: 7.19.6.3 The printf function
Summary
#include <stdio.h> int printf(const char * restrict format, ...);
The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.
7.19.6.1 The fprintf function
7.19.6.1.9
If a conversion specification is invalid, the behavior is **undefined**. If any argument is not the correct type for the corresponding conversion specification, the behavior is **undefined**.
Thus, your code calls Undefined Behavior [ (ISO C99 3.4.3) behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes **no requirements** ]
It should always be segfault right !?
Not necessarily, Undefined Behavior means that anything can happen.
source share