@thephd This is nice, but my bigger problem with _Generic is that it checks the semantics of non-matched expressions too.
ˋˋˋ
_Generic(x, struct a: x.x, int: x)
ˋˋˋ
This currently fails if x is an int. There are workarounds, but they are really annoying, hard to read and error prone.
ˋˋˋ
_Generic(x, struct a: _Generic(x, struct a: x, default: (struct a){0}).x, int: x)
ˋˋˋ
@DPA This is intentional and by-design for _Generic, but we do understand that many folk get really pissed off they can't use it as a way of writing more robust generic code. There are a few workarounds but they're mostly unsatisfactory and poor to use, as you've shown here.
We need investment in better. But that is going to require folks to start rolling up their sleeves and putting things out in compilers, to see what they can try to make happen.