Category "unions"

C++ Union Array differs in 32/64 bits

My code: union FIELD { int n; char c; const char *s; FIELD(){} FIELD(int v){ n = v; } FIELD(char v){ c = v; } FIELD(const char* v){

Using 'memcpy()' inside a class with a union

I have a class foo that manages data using small buffer optimization (SBO). When size < 16, the data is held locally (in buffer), otherwise it is stored on t

Unnamed union member has non-trivial operator

I am working on a project started back to 1980s, my mission is to substitute the primitive double with the Dummy class I create. The following is the simplified

struct in union nested - understanding behaviour of type punning

The following code uses a structure inside a union inside a structure inside a union. #include <cstdio> union { char abcd[4]; struct {

C++ union struct with struct member works on Clang and MSVC but not GCC

I am trying to define a union struct with some struct and primitive members overlapping in memory with a simple array. This works perfectly in Clang and MSVC, b