Bug 211044 - [WTF] Workaround gcc bug for unsigned bitfield related usual arithmetic conversions
Summary: [WTF] Workaround gcc bug for unsigned bitfield related usual arithmetic conve...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joonghun Park
Keywords: InRadar
Depends on:
Reported: 2020-04-26 02:12 PDT by Joonghun Park
Modified: 2020-04-27 03:09 PDT (History)
6 users (show)

See Also:

Patch (2.58 KB, patch)
2020-04-26 02:15 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joonghun Park 2020-04-26 02:12:11 PDT
(unsigned + signed) should return unsigned int type as a common type defined by usual arithmetic conversions.

But gcc 9.3.0 returns signed int type for this case.

I filed a bug for this issue on gcc bugzilla,

To workaround this, I originally submitted the patch, http://svn.webkit.org/repository/webkit/trunk@260715,
but according to Darin's comment, use unsigned integer suffix instead of static_cast<unsigned>.
Comment 1 Joonghun Park 2020-04-26 02:15:01 PDT
Created attachment 397614 [details]
Comment 2 EWS 2020-04-26 11:55:25 PDT
Committed r260727: <https://trac.webkit.org/changeset/260727>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397614 [details].
Comment 3 Radar WebKit Bug Importer 2020-04-26 11:56:17 PDT
Comment 4 Joonghun Park 2020-04-27 03:09:23 PDT
FYI, in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94767,
Jonathan Wakely left a comment for a c++ standard entry for this issue.


and the statement of this link is as below.

"A prvalue for an integral bit-field ([class.bit]) can be converted to a prvalue of type int if int can represent all the values of the bit-field; otherwise, it can be converted to unsigned int if unsigned int can represent all the values of the bit-field. If the bit-field is larger yet, no integral promotion applies to it. If the bit-field has an enumerated type, it is treated as any other value of that type for promotion purposes."

So I think gcc's build warning,

warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]

was valid one and this patch could be a proper fix, not just a workaround.