On Wed, Oct 07, 2020 at 06:03:16PM -0400, Tom Lane wrote: > I wrote: > > I'm tempted to propose the attached small code rearrangement, which > > might dissuade the compiler from thinking it can get away with this.
That patch does get hornet's -O2 build to again pass "make check". It doesn't harm the code, so we may as well use it. > > While I concur with your point that an old xlc version might not be > > that exciting, there could be other compilers doing the same thing > > in the future. > > After thinking about it a bit more, I'm not even convinced that what > xlc seems to be doing is illegal per C spec. There are no sequence > points within > > return list_make2(list_concat(directargs, orderedargs), > makeInteger(ndirectargs)); There is, however, a sequence point between list_length(directargs) and list_concat(), and the problem arises because xlc reorders those two. It's true that makeInteger() could run before or after list_concat(), but that alone would not have been a problem.