Existing implementation puts undef into padding bits which almost always
compiled into zeroes. However with -ftrivial-auto-var-init=pattern those undefs
became 0xAA pattern and break some code. We need to zero initialized them.
11.6 Initializers 6 To zero-initialize an object or reference of type T means: (6.3) — if T is a (possibly cv-qualified) union type, its padding bits (6.7) are initialized to zero bits 8 To value-initialize an object of type T means: (8.2) — if T is a (possibly cv-qualified) class type without a user-provided or deleted default constructor, then the object is zero-initialized and the semantic constraints for default-initialization are checked, and if T has a non-trivial default constructor, the object is default-initialized; 11.6.1 Aggregates 3 When an aggregate is initialized by an initializer list as specified in 11.6.4, the elements of the initializer list are taken as initializers for the elements of the aggregate, in order. Each element is *copy-initialized* from the corresponding initializer-clause. If the initializer-clause is an expression and a narrowing conversion (11.6.4) 8 If there are fewer initializer-clauses in the list than there are elements in a non-union aggregate, then each element not explicitly initialized is initialized as follows: If the aggregate is a union and the initializer list is empty, then (8.4) — if any variant member has a default member initializer, that member is initialized from its default member initializer; (8.5) — otherwise, the first member of the union (if any) is copy-initialized from an empty initializer list. 11.6.4 List-initialization (3.3) — Otherwise, if T is an aggregate, aggregate initialization is performed (3.4) — Otherwise, if the initializer list has no elements and T is a class type with a default constructor, the object is value-initialized. ... (3.10) — Otherwise, if the initializer list has no elements, the object is value-initialized
Looks like C does not require, as union is not aggregate, but a lot of code already relies on this behavior.
6.7.9 Initialization 10. If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static or thread storage duration is not initialized explicitly, then: — if it is a union, the first named member is initialized (recursively) according to these rules, and any padding is initialized to zero bits; 21. If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.