[Bug tree-optimization/79345] [6/7 Regression] passing yet-uninitialized member as argument to base class constructor should warn (-Wunitialized)

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Feb 21 11:26:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79345

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
11:14 < richi> In function ‘void branch_target_load_optimize(bool)’:
11:14 < richi> cc1plus: error: ‘call_saved’ may be used uninitialized in this 
               function [-Werror=maybe-uninitialized]
11:14 < richi> cc1plus: error: ‘*((void*)& call_saved +8)’ may be used 
               uninitialized in this function [-Werror=maybe-uninitialized]

In file included from /space/rguenther/src/svn/trunk/gcc/coretypes.h:365:0,
                 from /space/rguenther/src/svn/trunk/gcc/fixed-value.c:22:
/space/rguenther/src/svn/trunk/gcc/wide-int.h: In function ‘void
fixed_from_string(fixed_value*, const char*, machine_mode)’:
/space/rguenther/src/svn/trunk/gcc/wide-int.h:818:49: error: ‘*((void*)& w
+34359738360)’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   unsigned HOST_WIDE_INT high = this->get_val ()[len - 1];
                                 ~~~~~~~~~~~~~~~~^
/space/rguenther/src/svn/trunk/gcc/wide-int.h: In function ‘bool
fixed_convert_from_real(fixed_value*, machine_mode, const real_value*, bool)’:
/space/rguenther/src/svn/trunk/gcc/wide-int.h:818:49: error: ‘*((void*)& w
+34359738360)’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   unsigned HOST_WIDE_INT high = this->get_val ()[len - 1];
                                 ~~~~~~~~~~~~~~~~^

the above is from

 f->data.low = w.elt (0);

and

generic_wide_int <storage>::elt (unsigned int i) const
{
  if (i >= this->get_len ())
    return sign_mask ();
  else
    return this->get_val ()[i];

resulting in 0 >= get_len () (which is get_len == 0).

And then we have

11:32 < jakub> richi: looks like a bug in genemit.c
11:33 < jakub> richi: the pattern has (clobber (match_scratch:QI 6))
11:33 < jakub> richi: and it emits:
11:33 < jakub> ...
11:33 < jakub>   rtx operand6 ATTRIBUTE_UNUSED;
11:33 < jakub> ...
11:34 < richi> jakub: and yes, the fixed-value.c is if (len == 0) { ... do 
               nonsense .. } else { .. here we always come ...} ( not sure yet 
               how we arrive there)
11:34 < jakub>     operand6 = operands[6];
11:34 < jakub>     (void) operand6;
11:34 < jakub> ..
11:34 < richi> shouldn't that be optimized away?
11:34 < jakub> and then:
11:34 < richi> ah, early uninit runs too early I guess
11:34 < jakub> gen_rtx_SCRATCH (QImode)) (rather than using operand6)
11:35 < richi> yeah, before any optimization ...
11:35 < richi> not so intelligent for the memory stuff


And

In file included from /space/rguenther/src/svn/trunk/gcc/coretypes.h:365:0,
                 from /space/rguenther/src/svn/trunk/gcc/ipa-cp.c:105:
In member function ‘generic_wide_int<storage>&
generic_wide_int<T>::operator=(const T&) [with T = wi::hwi_with_prec; storage =
wide_int_storage]’,
    inlined from ‘void ipcp_store_vr_results()’ at
/space/rguenther/src/svn/trunk/gcc/ipa-cp.c:4962:49,
    inlined from ‘unsigned int ipcp_driver()’ at
/space/rguenther/src/svn/trunk/gcc/ipa-cp.c:5003:25:
/space/rguenther/src/svn/trunk/gcc/wide-int.h:881:3: error:
‘*((void*)&<anonymous> +8)’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   storage::operator = (x);
   ^~~~~~~

              vr.min = vr.max = wi::zero (INT_TYPE_SIZE);

generic_wide_int <storage>::operator = (const T &x)
{
  storage::operator = (x);

can be avoided by removign the assignment (not sure about followup isssues
where we look at min/max for VR_VARYING).

That seems to be it, leaving the genemit issue.

Index: genemit.c
===================================================================
--- genemit.c   (revision 245601)
+++ genemit.c   (working copy)
@@ -518,6 +518,8 @@ gen_expand (md_rtx_info *info)
        {
          for (i = 0; i < stats.num_operand_vars; i++)
            {
+             if (i > stats.max_dup_opno && i <= stats.max_scratch_opno)
+               continue;
              printf ("    operand%d = operands[%d];\n", i, i);
              printf ("    (void) operand%d;\n", i);
            }

results in

/space/rguenther/src/svn/gcc-7-branch/gcc/config/i386/i386.md: In function
‘rtx_def* gen_tls_global_dynamic_32(rtx, rtx, rtx, rtx)’:
/space/rguenther/src/svn/gcc-7-branch/gcc/config/i386/i386.md:13535:9: warning:
variable ‘operands’ set but not used [-Wunused-but-set-variable]
   return "call\t{*%p3@GOT(%1)|[DWORD PTR %p3@GOT[%1]]}";
         ^
/space/rguenther/src/svn/gcc-7-branch/gcc/config/i386/i386.md: In function
‘rtx_def* gen_tls_local_dynamic_base_32(rtx, rtx, rtx)’:
/space/rguenther/src/svn/gcc-7-branch/gcc/config/i386/i386.md:13655:9: warning:
variable ‘operands’ set but not used [-Wunused-but-set-variable]
       (clobber (match_scratch:SI 4))
         ^

we can put ATTRIBUTE_UNUSED on operands.

That allows us to build stage2 w/o new warnings...


More information about the Gcc-bugs mailing list