Both arrays should have the same size and layout. Of course, if you initialize something with m_V
, then all calls to m_M
undefined behavior; the compiler may, for example, note that m_V
has changed in m_V
and returns an earlier value, even if you modified the element through m_M
. I really used the compiler that did this in the distant past. I would avoid access when the union is not displayed, say by passing a link to m_V
and a link to m_M
to the same function.
source share