https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94952
Bug ID: 94952 Summary: Possible false positive of uninitialized variable usage during release build in gimple-ssa-store-merging.c Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: stefansf at linux dot ibm.com Target Milestone: --- Created attachment 48450 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48450&action=edit initialize variables `bitpos`, `bitregion_start`, and `bitregion_end` While bootstrapping GCC on S/390 with --enable-checking=release the following warnings are raised: gcc/gimple-ssa-store-merging.c: In member function 'virtual unsigned int {anonymous}::pass_store_merging::execute(function*)': gcc/gimple-ssa-store-merging.c:1412:24: error: 'bitregion_end.poly_int_pod<1, long unsigned int>::coeffs[0]' may be used uninitialized in this fu nction [-Werror=maybe-uninitialized] 1412 | , ops { op0r, op1r } | ^ gcc/gimple-ssa-store-merging.c:4672:32: note: 'bitregion_end.poly_int_pod<1, long unsigned int>::coeffs[0]' was declared here 4672 | poly_uint64 bitregion_start, bitregion_end; | ^~~~~~~~~~~~~ gcc/gimple-ssa-store-merging.c:1412:24: error: 'bitregion_start.poly_int_pod<1, long unsigned int>::coeffs[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized] 1412 | , ops { op0r, op1r } | ^ gcc/gimple-ssa-store-merging.c:4672:15: note: 'bitregion_start.poly_int_pod<1, long unsigned int>::coeffs[0]' was declared here 4672 | poly_uint64 bitregion_start, bitregion_end; | ^~~~~~~~~~~~~~~ In file included from gcc/coretypes.h:449, from gcc/gimple-ssa-store-merging.c:143: gcc/poly-int.h:2063:21: error: 'bitpos.poly_int<1, long unsigned int>::<anonymous>.poly_int_pod<1, long unsigned int>::coeffs[0]' may be used uni nitialized in this function [-Werror=maybe-uninitialized] 2063 | if (a.coeffs[i] % b != 0) | ~~~~~~~~~~~~^~~ gcc/gimple-ssa-store-merging.c:4671:24: note: 'bitpos.poly_int<1, long unsigned int>::<anonymous>.poly_int_pod<1, long unsigned int>::coeffs[0]' was declared here 4671 | poly_uint64 bitsize, bitpos; | ^~~~~~ Function `mem_valid_for_store_merging` initializes the aforementioned variables `bitpos`, `bitregion_start`, and `bitregion_end` if it returns a value different than `NULL_TREE`. tree base_addr = mem_valid_for_store_merging (lhs, &bitsize, &bitpos, &bitregion_start, &bitregion_end); Thus the local variable `invalid` equals `true` in case the aforementioned variables are uninitialized. bool invalid = (base_addr == NULL_TREE || /* ... */); What follows is a check on `invalid`: if (invalid) ; else if (rhs_valid_for_store_merging_p (rhs)) { // ... } else if (TREE_CODE (rhs) != SSA_NAME) invalid = true; else { // ... (*) } // ... if (invalid || /* ... */) return terminate_all_aliasing_chains (NULL, stmt); In total we have that in case `bitpos`, `bitregion_start`, or `bitregion_end` is uninitialized, then `invalid` equals true and the function returns prior an access which renders the warnings as false positives. Interestingly, if (*) gets removed which cannot be taken in case the variables are uninitialized, then the warnings disappear which endorses the suspicion of a false positive. The attached patch fixes the warnings by initializing `bitpos`, `bitregion_start`, or `bitregion_end` to zero.