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

     1  typedef unsigned char bool;
     2  typedef unsigned char uint8_t;
     3  typedef unsigned short uint16_t;
     4  typedef unsigned uint32_t;
     5  
     6  typedef struct {
     7  	bool is_inline:1;
     8  	bool visible:1;
     9  	bool named:1;
    10  	bool extra:1;
    11  	bool has_changes:1;
    12  	bool is_missing:1;
    13  	bool is_keyword:1;
    14  	uint8_t symbol;
    15  	uint8_t padding_bytes;
    16  	uint8_t size_bytes;
    17  	uint8_t padding_columns;
    18  	uint8_t padding_rows:4;
    19  	uint8_t lookahead_bytes:4;
    20  	uint16_t parse_state;
    21  } SubtreeInlineData;
    22  
    23  typedef struct {
    24  	uint32_t child_count;
    25  } SubtreeHeapData;
    26  
    27  typedef union {
    28  	SubtreeInlineData data;
    29  	SubtreeHeapData *ptr;
    30  } MutableSubtree;
    31  
    32  int main() {
    33  	MutableSubtree ms;
    34  	ms = (MutableSubtree) { .data = {} };
    35  	void *p = (void *)0;
    36  	ms = (MutableSubtree) { .ptr = p };
    37  	return ms.ptr != 0;
    38  }