fix implicit zero initializer.
commitb1672eab399fdce2c050e8aa07767489a2071981
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Thu, 6 Apr 2017 13:50:23 +0000 (6 15:50 +0200)
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Fri, 19 May 2017 03:35:01 +0000 (19 05:35 +0200)
tree7a7edd535f4747c5e8f84dc6f1ab3181e50746a3
parent816e13f57644116daf20debe548e3e53ec4e5073
fix implicit zero initializer.

The C standard requires that, when initializing an aggregate, all
fieds not explicitly initialized shall be implicity zero-initialized
(more exactly "the same as objects that have static storage duration"
[6.7.9.21]).

Until now sparse didn't did this.
Fix this (when an initializer is present and the object not a scalar)
by first storing zeroes in the whole object before doing the
initialization of each fields explicitly initialized.

Note 1: this patch initialize the *whole* aggregate while the
standard only requires that existing fields are initialized.
Thanks to Linus to notice this.
Note 2: this implicit initialization is not needed if all fields are
        explicitly initialized but is done anyway, for the moment.
Note 3: the code simplify nicely when there is a single field that is
        initialized, much less so when there is several ones.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
linearize.c
validation/linear/bitfield-init-zero.c [new file with mode: 0644]
validation/linear/struct-init-full.c [new file with mode: 0644]
validation/linear/struct-init-partial.c [new file with mode: 0644]