const Boo *constBoo;
Boo *nonConstBoo;
nonConstBoo = ((union {const Boo *_q; Boo *_nq;})constBoo)._nq;
Is the above construct valid in C11, or is it only GCC/clang extension that you can cast a pointer to an anonymous union in this fashion? If it is not valid, is there any other way to write an equivalent expression in valid C11 code?
The intention was to emulate C++ const_cast that would be C11 compatible and provide some rudimentary type safety. An explicit cast from const to non-const pointer will trigger a warning with -Wcast-qual option, which is undesirable.