Unexpected behavior with a construction with initialization of the bit field enum C ++ 14

I have a structure that has a bit field that is of type enum:

enum TCDATA_FORMAT { a, b, c, d  }; 
struct ctypetc { TCDATA_FORMAT Input : 16; TCDATA_FORMAT Output : 16; };

and before C ++ 11 (VS2013) this initialization worked fine:

ctypetc ctyp = { b, c };

But with C ++ 14 (VS2015 update 1) it initializes input and output to 0. Does anyone know why? I guess this has something to do with enumerated bit fields.

edit: If I try:

ctyp.Input = b;
ctyp.Output = c;

It works great.

+4
source share

Source: https://habr.com/ru/post/1650590/


All Articles