another -Wunsequenced topic

dt71 at gmx.com dt71 at gmx.com
Mon Jul 8 11:44:39 UTC 2013


Well, this turned out to be a semi-false alarm. A week ago, for a short time, there was a bug in Clang. There is no undefined behavior in

   ptr = func(++ptr);,

partially because a function call introduces a sequence point in C, but Clang did not respect this at that time. However,

   x = func1(++ptr) + func2(++ptr);

is compiler-dependent. Additionally, if func() turns out to be a macro, rather than a native function, then undefined behavior (due to unsequencedness) occurs. According to the manpage for ntohl(): "On machines which have a byte order which is the same as the network order, routines are defined as null macros.". This can bite libstand on big-endian systems

So in the end, Clang has accidentally pointed me to an irrelated bug, and induced some unnecessary code changes. lolz


More information about the freebsd-current mailing list