New issue
Advanced search Search tips

Issue 763138 link

Starred by 1 user

Issue metadata

Status: Archived
Owner: ----
Closed: Jan 10
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

Windows compilation fails on enum switch statement without `default` case.

Project Member Reported by lgar...@chromium.org, Sep 7 2017

Issue description

It is often desirable (example: [1]) to have a switch statement over an enum with one case for every value:

    enum MyEnum {
      VAL_1,
      VAL_2
    };

    int f(MyEnum val) {
      switch (val) {
        case VAL_1:
          return 1;
        case VAL_2:
          return 2;
      }
    }

This forces every enum value to be accounted for at compile-time. If you add a value to the enum without adding it to such a switch statement, you get `error: enumeration value 'VAL_3' not handled in switch [-Werror,-Wswitch]`.

However, this fails to compile on the Windows bots. Fixing it always requires extra two round-trips for me:
- Add a `default:` case with `NOTREACHED()`.
  - *Still* get a Windows error.
- Add a bogus return statement (returning the "safest" enum value) after `NOTREACHED()`.
  - Passes trybots.

It would be nice if all of these situations compiled consistently across platforms. It would be nicest if the initial code snippet above works on all platforms, though.

[1] https://cs.chromium.org/chromium/src/content/browser/devtools/protocol/security_handler.cc
 
Labels: OS-Windows
Status: Archived (was: Untriaged)
Archiving P3s older than 1 year with no owner or component.

Sign in to add a comment