I do not know the low level ins and outs of the C language, but here's my speculation:
Since you've already established that the printf() function is line buffered, the buffer needs to be emptied and pushed to the standard output. I suppose this happens automatically when the program terminates. That's why your first example has an output on Linux, but the second does not.
Why it works on Windows is probably because the implementation of printf() is different and perhaps there's no line buffering there, but everything immediately goes to the standard output.
An important thing: where the C standard does not specify the internal behaviour of a function, the implementer does whatever they feel happy with, hence different compilers produce different output.
DISCLAIMER: these are just speculations, but if I'd need to make a guess, this is what I'd go with.