Re:C is not your friend: sizeof and side-effects
by slrz on Wednesday April 19, 2017 @06:42PM
(#14152448)
Some libraries explicitly document whether a given interface may be implemented as a macro. The C standard library and POSIX make these things a part of the specification. See getc vs. fgetc for example.
It's not uncommon to replace a function with a wrapper macro later on in an attempt to debug something or trace execution or whatever. It's not really realistic to expect that when such a replacement is done that they go analyze every possible call site to see if sizeof() results in side-effect evaluation or not.
This is just another case of C being a language built out of undefined behavior.