News for hackers. Stuff that matters.
Re:C is not your friend: sizeof and side-effects by kllrnohj on Wednesday April 19, 2017 @05:28PM (#14151955)
You're unnecessarily aggressive about blaming the caller. Whose to say that the caller didn't do their due diligence, but instead that the callee changed itself later on?

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.

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.