mercredi 5 septembre 2018

Enum bitfield and aggregate initialization

The following code is accepted by clang 6.0.0 but rejected by gcc 8.2

enum class E {
  Good, Bad,
};

struct S {
  E e : 2;
  int dummy;
};

S f() {
  return {E::Good, 100};
}

https://godbolt.org/z/A4LBuZ

The GCC complains

error: could not convert '{Good, 100}' from '' to 'S'

Which one is correct? Where in the standard talks about this situation?

Aucun commentaire:

Enregistrer un commentaire