On 17/12/15 21:02, Paul Eggert wrote: > On 12/17/2015 06:19 AM, Pádraig Brady wrote: >> - long int result = INT_MULTIPLY_WRAPV (a, b); >> + long int result = a * b; > > This doesn't look right, because a * b could overflow which would lead > to undefined behavior. INT_MULTIPLY_WRAPV does not rely on undefined > behavior due to integer overflow, which is the point of that example.
Right. The issue I have with the example is that INT_MULTIPLY_WRAPV() takes 3 arguments, while only 2 are provided. > I tracked this down to what appears to be a compiler bug in GCC, filed a > bug report with the GCC folks (GCC bug 68971), and installed the > attached patch instead. Right. I see the undefined code is never called or added to the translation unit. In case gcc decides to continue to warn in this case, I suppose we could avoid the undefined code by promoting to a wider type and explicitly truncating the result (though that might need __int128 if available for your new 64 bit case). thanks, Pádraig.