modernc.org/ccgo/v3@v3.16.14/lib/testdata/bug/bitfield.c (about)

     1  typedef struct {
     2  	short a;
     3  	unsigned short b:12;
     4  	unsigned char c:1;
     5  } s;
     6  
     7  s f()
     8  {
     9  	return (s) {
    10  		.b = 0xfef,
    11  	};
    12  }
    13  
    14  s g()
    15  {
    16  	return (s) {
    17  		.b = 0xfef,
    18  		.c = 1,
    19  	};
    20  }
    21  
    22  int main()
    23  {
    24  	s s;
    25  	s = f();
    26  	if (s.b != 0xfef) {
    27  		return __LINE__;
    28  	}
    29  
    30  	if (s.c) {
    31  		return __LINE__;
    32  	}
    33  
    34  	s = g();
    35  	if (s.b != 0xfef) {
    36  		return __LINE__;
    37  	}
    38  
    39  	if (!s.c) {
    40  		return __LINE__;
    41  	}
    42  
    43  	return 0;
    44  }