All challenges
Multiple ChoiceIntermediate 45s

Union Active Member UB

Reading a member of a union other than the one most recently written (for non-common-initial-sequence types) is:
Options
  1. 1Well-defined and yields an unspecified value of the type of the member being read
  2. 2Undefined behavior (except for common initial sequence in standard-layout structs)
  3. 3A constraint violation that is diagnosed and rejected at compile time by the compiler
  4. 4Only undefined behavior if the union itself is non-trivial, otherwise it is fine

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle