Bug 208060

Summary: Warning spam from ResourceLoaderOptions.h (Bots need updating to compiler without this issue)
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: WebKit Misc.Assignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, berto, darin, dpino, erack, mcatanzaro, pnormand, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   

Description Michael Catanzaro 2020-02-21 09:17:51 PST
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:205:24: warning: ‘WebCore::ResourceLoaderOptions::sendLoadCallbacks’ is too small to hold all values of ‘enum class WebCore::SendCallbackPolicy’
  205 |     SendCallbackPolicy sendLoadCallbacks : bitWidthOfSendCallbackPolicy;
      |                        ^~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:206:27: warning: ‘WebCore::ResourceLoaderOptions::sniffContent’ is too small to hold all values of ‘enum class WebCore::ContentSniffingPolicy’
  206 |     ContentSniffingPolicy sniffContent : bitWidthOfContentSniffingPolicy;
      |                           ^~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:207:35: warning: ‘WebCore::ResourceLoaderOptions::sniffContentEncoding’ is too small to hold all values of ‘enum class WebCore::ContentEncodingSniffingPolicy’
  207 |     ContentEncodingSniffingPolicy sniffContentEncoding : bitWidthOfContentEncodingSniffingPolicy;
      |                                   ^~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:208:25: warning: ‘WebCore::ResourceLoaderOptions::dataBufferingPolicy’ is too small to hold all values of ‘enum class WebCore::DataBufferingPolicy’
  208 |     DataBufferingPolicy dataBufferingPolicy : bitWidthOfDataBufferingPolicy;
      |                         ^~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:209:29: warning: ‘WebCore::ResourceLoaderOptions::storedCredentialsPolicy’ is too small to hold all values of ‘enum class WebCore::StoredCredentialsPolicy’
  209 |     StoredCredentialsPolicy storedCredentialsPolicy : bitWidthOfStoredCredentialsPolicy;
      |                             ^~~~~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:210:25: warning: ‘WebCore::ResourceLoaderOptions::securityCheck’ is too small to hold all values of ‘enum class WebCore::SecurityCheckPolicy’
  210 |     SecurityCheckPolicy securityCheck : bitWidthOfSecurityCheckPolicy;
      |                         ^~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:211:27: warning: ‘WebCore::ResourceLoaderOptions::certificateInfoPolicy’ is too small to hold all values of ‘enum class WebCore::CertificateInfoPolicy’
  211 |     CertificateInfoPolicy certificateInfoPolicy : bitWidthOfCertificateInfoPolicy;
      |                           ^~~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:212:37: warning: ‘WebCore::ResourceLoaderOptions::contentSecurityPolicyImposition’ is too small to hold all values of ‘enum class WebCore::ContentSecurityPolicyImposition’
  212 |     ContentSecurityPolicyImposition contentSecurityPolicyImposition : bitWidthOfContentSecurityPolicyImposition;
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:213:25: warning: ‘WebCore::ResourceLoaderOptions::defersLoadingPolicy’ is too small to hold all values of ‘enum class WebCore::DefersLoadingPolicy’
  213 |     DefersLoadingPolicy defersLoadingPolicy : bitWidthOfDefersLoadingPolicy;
      |                         ^~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:214:19: warning: ‘WebCore::ResourceLoaderOptions::cachingPolicy’ is too small to hold all values of ‘enum class WebCore::CachingPolicy’
  214 |     CachingPolicy cachingPolicy : bitWidthOfCachingPolicy;
      |                   ^~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:215:27: warning: ‘WebCore::ResourceLoaderOptions::sameOriginDataURLFlag’ is too small to hold all values of ‘enum class WebCore::SameOriginDataURLFlag’
  215 |     SameOriginDataURLFlag sameOriginDataURLFlag : bitWidthOfSameOriginDataURLFlag;
      |                           ^~~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:216:22: warning: ‘WebCore::ResourceLoaderOptions::initiatorContext’ is too small to hold all values of ‘enum class WebCore::InitiatorContext’
  216 |     InitiatorContext initiatorContext : bitWidthOfInitiatorContext;
      |                      ^~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:217:24: warning: ‘WebCore::ResourceLoaderOptions::serviceWorkersMode’ is too small to hold all values of ‘enum class WebCore::ServiceWorkersMode’
  217 |     ServiceWorkersMode serviceWorkersMode : bitWidthOfServiceWorkersMode;
      |                        ^~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:218:26: warning: ‘WebCore::ResourceLoaderOptions::applicationCacheMode’ is too small to hold all values of ‘enum class WebCore::ApplicationCacheMode’
  218 |     ApplicationCacheMode applicationCacheMode : bitWidthOfApplicationCacheMode;
      |                          ^~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:219:28: warning: ‘WebCore::ResourceLoaderOptions::clientCredentialPolicy’ is too small to hold all values of ‘enum class WebCore::ClientCredentialPolicy’
  219 |     ClientCredentialPolicy clientCredentialPolicy : bitWidthOfClientCredentialPolicy;
      |                            ^~~~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:220:21: warning: ‘WebCore::ResourceLoaderOptions::preflightPolicy’ is too small to hold all values of ‘enum class WebCore::PreflightPolicy’
  220 |     PreflightPolicy preflightPolicy : bitWidthOfPreflightPolicy;
      |                     ^~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebCore/loader/ResourceLoaderOptions.h:221:28: warning: ‘WebCore::ResourceLoaderOptions::loadedFromOpaqueSource’ is too small to hold all values of ‘enum class WebCore::LoadedFromOpaqueSource’
  221 |     LoadedFromOpaqueSource loadedFromOpaqueSource : bitWidthOfLoadedFromOpaqueSource;
      |                            ^~~~~~~~~~~~~~~~~~~~~~
Comment 1 Michael Catanzaro 2020-02-21 09:37:02 PST
Yusuke, I think we just need to roll out r256482? Or switch from using enum classes to integer constants? GCC really doesn't like this. It doesn't even have a name for this warning, so it can't be disabled afaik.
Comment 2 Yusuke Suzuki 2020-02-29 01:25:32 PST
(In reply to Michael Catanzaro from comment #1)
> Yusuke, I think we just need to roll out r256482? Or switch from using enum
> classes to integer constants? GCC really doesn't like this. It doesn't even
> have a name for this warning, so it can't be disabled afaik.

Can we disable this warning on GCC? Using `unsigned` looks like worse than using enum.
Comment 3 Michael Catanzaro 2020-02-29 08:14:25 PST
(In reply to Yusuke Suzuki from comment #2)
> Can we disable this warning on GCC? Using `unsigned` looks like worse than
> using enum.

I don't think so. Because the warning doesn't have a name (like, say, -Wsign-compare), there's no way to pass a build flag to disable it or to suppress it using a #pragma. If think if we really want to use bitfields here, then we need to change these to no longer use enums.
Comment 4 Eike Rathke 2020-02-29 08:36:44 PST
You might be interested in how LibreOffice handles this:
https://opengrok.libreoffice.org/xref/core/include/o3tl/typed_flags_set.hxx?r=b612cf0e
as used for example
https://opengrok.libreoffice.org/xref/core/vcl/inc/salptype.hxx?r=b4c6ac33#27
Comment 5 Yusuke Suzuki 2020-02-29 12:56:15 PST
(In reply to Michael Catanzaro from comment #3)
> (In reply to Yusuke Suzuki from comment #2)
> > Can we disable this warning on GCC? Using `unsigned` looks like worse than
> > using enum.
> 
> I don't think so. Because the warning doesn't have a name (like, say,
> -Wsign-compare), there's no way to pass a build flag to disable it or to
> suppress it using a #pragma. If think if we really want to use bitfields
> here, then we need to change these to no longer use enums.

We really want. So unsigned is only the answer. I cannot understand why GCC is emitting such a warning without flags, clang does mot emit it :(
Comment 6 Darin Adler 2020-03-01 11:29:13 PST
It’s amazing that we can actually use enums with bit fields in other compilers. I’m sorry to hear that gcc is holding us back. We wanted this for years!
Comment 7 Michael Catanzaro 2020-03-02 07:10:19 PST
Well the warning makes sense to me. We have a clear declared width for the enum and are trying to stuff it into a field that is too small to hold it.

Maybe the warning would go away if we remove the width...? I'll try.
Comment 8 Michael Catanzaro 2020-03-02 07:24:05 PST
(In reply to Michael Catanzaro from comment #7)
> Maybe the warning would go away if we remove the width...? I'll try.

Nope. Was worth a try....
Comment 9 Michael Catanzaro 2020-03-02 14:21:10 PST
So Phil found: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. Good job, Phil! It's fixed in GCC 8.4+, 9.3+, and 10.

I'm testing with the GCC 10.0.1 Feb 16 snapshot that we have in Fedora 32, and the warnings are indeed gone, so I'm going to close this.
Comment 10 Yusuke Suzuki 2020-03-04 14:14:54 PST
(In reply to Michael Catanzaro from comment #9)
> So Phil found: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. Good job,
> Phil! It's fixed in GCC 8.4+, 9.3+, and 10.
> 
> I'm testing with the GCC 10.0.1 Feb 16 snapshot that we have in Fedora 32,
> and the warnings are indeed gone, so I'm going to close this.

That sounds really nice!
Comment 11 Alberto Garcia 2020-03-10 07:35:13 PDT
I understand that this warning is a false positive?

In other words, is the code built with the affected GCC versions safe to use?
Comment 12 Michael Catanzaro 2020-03-10 07:49:25 PDT
I assume it's a false-positive, yes.
Comment 13 Brady Eidson 2020-04-19 10:17:37 PDT
(In reply to Michael Catanzaro from comment #9)
> So Phil found: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. Good job,
> Phil! It's fixed in GCC 8.4+, 9.3+, and 10.
> 
> I'm testing with the GCC 10.0.1 Feb 16 snapshot that we have in Fedora 32,
> and the warnings are indeed gone, so I'm going to close this.

But.... our EWS bots are still showing the warning. Thousands of times per build.

So there's still an issue in the WebKit Open Source project.

Who's task is it to update the bots to newer GCC or clang?
Comment 14 Michael Catanzaro 2020-05-10 13:07:55 PDT
(In reply to Brady Eidson from comment #13)
> Who's task is it to update the bots to newer GCC or clang?

Nobody responded to this?

I highly doubt the bots will be updated to a newer GCC. If avoiding warnings on the bots is desired, we'll have to suppress them by either changing WebKit's code or build system.
Comment 15 Darin Adler 2020-05-10 13:46:45 PDT
The bots will *never* be updated? That can’t be right. When would they normally be updated if there was no GCC bug motivating us?

Separately, we should make the EWS system filter out these warnings as a stopgap measure.
Comment 16 Michael Catanzaro 2020-05-10 14:47:48 PDT
I think they're updated for new Debian releases (every 2-3 years).
Comment 17 Darin Adler 2020-05-10 15:16:25 PDT
Does someone know when the next Debian release is coming?
Comment 18 Michael Catanzaro 2020-05-10 15:51:38 PDT
Guess: 1-2 more years.

Anyway, better wait for someone who actually runs the bots to respond.
Comment 19 Philippe Normand 2020-05-11 00:41:07 PDT
The bots using the Flatpak SDK build with GCC 9.3.0. Only Adrian's EWS is left to migrate, AFAIK...