C++ Logo

std-discussion

Advanced search

Re: UB in P2641 'Checking if a union alternative is active'

From: M.P. <dbc_at_[hidden]>
Date: Mon, 19 Jun 2023 20:28:58 -0000
> How so? c1 is a punned reference to u, and c2 is a punned reference to
> u.i, so [basic.lval]/11 applies, does it not? Meanwhile, reading u.c
> for c3 would access an inactive variant.

'u.c' is pointer-interconvertible with 'u' (and 'u.i'), so '(char&)u'
refers to 'u.c'.

Received on 2023-06-19 20:29:01