Bug 196829

Summary: Enable -fwrapv and /d2UndefIntOverflow
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: NEW ---    
Severity: Normal CC: Hironori.Fujii, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Yusuke Suzuki 2019-04-11 14:29:27 PDT
We already see a bug caused by signed integer overflow UB.
If it does not hurt performance, we should enable this option to avoid such an UB.
Personally, I think this UB is one of the most common UBs resulting in an actual bug.

An attempt making this behavior by default in the spec exists[1].
While the main focus of that proposal is accepted, "making signed overflow well-defined" is rejected.
So we should enable -fwrapv / d2UndefIntOverflow manually in the WebKit side.

> Status-quo If a signed operation would naturally produce a value that is not within the range of the result type, the behavior is undefined.
> The author had hoped to make this well-defined as wrapping (the operations produce the same value bits as for the corresponding unsigned type), but WG21 had strong resistance against this.

[1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0907r2.html
Comment 1 Yusuke Suzuki 2019-04-11 15:15:40 PDT
Maybe, this would be my weekend task just for fun.