Fix the static initializer build with UBSan 56/94856/2
authorSlava Barinov <v.barinov@samsung.com>
Wed, 28 Sep 2016 14:44:47 +0000 (17:44 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Wed, 16 Nov 2016 04:32:08 +0000 (20:32 -0800)
commitcaea219f27f51b93f57ec45f65541d895834cc6d
tree323321108ebbc3e1371108f42589b6681b68cc28
parent61a398eed4de0fc1906e9e9ba77da4c9edabe1de
Fix the static initializer build with UBSan

The idea is borrowed from the upstream 56ac70e (trunk@212499).
Without the check initializer is not fold to constant and therefore structure
cannot be initialized.

* gcc/fold-const.c (tree_single_nonzero_warnv_p): Check if local object
is WEAK to remove then NULL check.
* gcc.dg/ubsan/static-init-null.c: New testcase.

Change-Id: I895708e5ae8b1cffcdbdf060ce8894a029937e75
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
gcc/fold-const.c
gcc/testsuite/gcc.dg/ubsan/static-init-null.c [new file with mode: 0644]