New issue
Advanced search Search tips

Issue 621097 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug

Blocking:
issue 504657



Sign in to add a comment

Come up with story for Wmicrosoft-enum-value

Project Member Reported by thakis@chromium.org, Jun 17 2016

Issue description

Split off from  bug 504657 . -Wmicrosoft-enum-value fires all over the place if not suppressed, with "enumerator value is not representable in the underlying type 'int'" for enums that store e.g. DWORDS (`enum { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES };`) or literals with the high bit set (`MD_NTSTATUS_WIN_STATUS_DEVICE_ALREADY_ATTACHED = 0xC0000038`).

This isn't a useful warning currently since it fires all over the place in system headers, and all that code does work. One idea is to instead warn when that enum value is compared to 0, since that will have different behavior on MS and non-MS. I tried implementing this a few months ago, but we don't remember if a literal was sign-converted in the AST.

Maybe we should remove the current warning from clang for now, since it's not super useful that every project has to suppress it.
 

Comment 1 by r...@chromium.org, Jun 17 2016

I think a better check would be to remember which enums have the wrong sign in MSVC mode, and then if we see an ordering comparison on a value of that enum, we can warn:

// Underlying type is 'unsigned' on Linux and 'int' on Windows
enum E {
  E0 = 1,
  E1 = 0xffffffff,
};
void f(int v) {
  if (v < E1) { // warn
  ...
}

Such a warning would probably have to look through implicit integer promotions.

Anyway, we can turn it off by default and move it out of -Wmicrosoft for now.

Comment 2 by thakis@chromium.org, Jun 22 2016

Here's my wip.patch from a while ago. `// XXX this ruins our life` marks the spot where the ast is currently lossy.
wip.patch
4.5 KB Download
Labels: -Clang clang
I turned this warning off by default for now in clang r302187.

Comment 4 by thakis@chromium.org, Jun 23 2017

https://codereview.chromium.org/2954703002 removed Wno-microsoft-enum-value, since that warning is now disabled by default. So let's close this bug here.

I filed https://bugs.llvm.org/show_bug.cgi?id=33575 for making the warning in clang useful and for turning it on again.

Comment 5 by thakis@chromium.org, Jun 23 2017

Owner: thakis@chromium.org
Status: Fixed (was: Untriaged)

Sign in to add a comment