public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/38271]  New: Spurious / missing "... used uninitialized in this function" warning
@ 2008-11-26  2:48 d dot g dot gorbachev at gmail dot com
  2008-11-26  2:50 ` [Bug middle-end/38271] " d dot g dot gorbachev at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2008-11-26  2:48 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

gcc -S -O1 -Wuninitialized uninitialized.c

GCC 4.4.0 20081121:
  warning: 's' is used uninitialized in this function

GCC 4.3.2:
  warning: ‘i’ may be used uninitialized in this function


-- 
           Summary: Spurious / missing "... used uninitialized in this
                    function" warning
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot g dot gorbachev at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
@ 2008-11-26  2:50 ` d dot g dot gorbachev at gmail dot com
  2008-11-26  2:55 ` [Bug middle-end/38271] [4.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2008-11-26  2:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from d dot g dot gorbachev at gmail dot com  2008-11-26 02:48 -------
Created an attachment (id=16772)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16772&action=view)
testcase


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
  2008-11-26  2:50 ` [Bug middle-end/38271] " d dot g dot gorbachev at gmail dot com
@ 2008-11-26  2:55 ` pinskia at gcc dot gnu dot org
  2008-11-26 10:02 ` rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-26  2:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-11-26 02:54 -------
What the *#$^*(#^&$*(:
  SR.3_5 = p_1(D)->c;
  SR.4_6 = VIEW_CONVERT_EXPR<long long unsigned int>(*p_1(D));
  SR.4_7 = SR.4_6 & 4294967295;
  SR.5_8 = (unsigned int) SR.4_7;
  s.0.c ={v} SR.3_5;
  SR.6_10 = VIEW_CONVERT_EXPR<long long unsigned int>(s.0);
  SR.7_11 = SR.6_10 & 0x0ffffffff00000000;
  SR.8_12 = (long long unsigned int) SR.5_8;
  SR.9_13 = SR.7_11 | SR.8_12;
  s.0 ={v} VIEW_CONVERT_EXPR<struct xxx>(SR.9_13);

This is so wrong.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aoliva at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2008-11-26 02:54:24
               date|                            |
            Summary|Spurious / missing "... used|[4.4 Regression] Spurious /
                   |uninitialized in this       |missing "... used
                   |function" warning           |uninitialized in this
                   |                            |function" warning
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
  2008-11-26  2:50 ` [Bug middle-end/38271] " d dot g dot gorbachev at gmail dot com
  2008-11-26  2:55 ` [Bug middle-end/38271] [4.4 Regression] " pinskia at gcc dot gnu dot org
@ 2008-11-26 10:02 ` rguenth at gcc dot gnu dot org
  2008-12-03 16:29 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-26 10:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-11-26 10:00 -------
Doesn't happen on 64bit x86_64.  Testcase which doesn't warn with 4.3:

struct xxx {
    short a;
    short b;
    void *c;
};

void bar(struct xxx);

void foo(struct xxx *p, int i)
{
  struct xxx s = *p;
  if (s.a) i++;
  bar(s);
}

but indeed, SRA does bullshit here, cost-wise and correctness-wise.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|                            |i686-*-*
      Known to work|                            |4.3.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (2 preceding siblings ...)
  2008-11-26 10:02 ` rguenth at gcc dot gnu dot org
@ 2008-12-03 16:29 ` jakub at gcc dot gnu dot org
  2008-12-03 16:40 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-03 16:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-12-03 16:28 -------
I can't reproduce this any longer since
http://gcc.gnu.org/viewcvs?view=rev&revision=142396


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (3 preceding siblings ...)
  2008-12-03 16:29 ` jakub at gcc dot gnu dot org
@ 2008-12-03 16:40 ` rguenth at gcc dot gnu dot org
  2008-12-05 12:58 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-03 16:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-12-03 16:38 -------
Still warns for

truct xxx {
    short a;
    short b;
    void *c;
};

void bar(struct xxx);

void foo(struct xxx *p, int i)
{
  struct xxx s0 = *p;
  struct xxx s = s0;
  if (s.a) i++;
  bar(s);
}

at -O -m32 -Wuninitialized.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (4 preceding siblings ...)
  2008-12-03 16:40 ` rguenth at gcc dot gnu dot org
@ 2008-12-05 12:58 ` rguenth at gcc dot gnu dot org
  2008-12-05 13:06 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-05 12:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-12-05 12:57 -------
This is sra_build_assignment/sra_build_bf_assignments way of "lowering" a
BIT_FIELD_REF to integer arithmetic.  We hit the !INTEGRAL_TYPE_P (TREE_TYPE
(var)) paths and for

  BIT_FIELD_REF <*p_1(D), 32, 0>

we create VIEW_CONVERT_EXPR <long long> (*p) and extract the lower/upper 32
bits by shifting and masking.  This obviously "uses" possibly uninitialized
parts of *p or s0.  The problem here is that we interestingly split the
initialization of s0 to the upper part

  s0.c ={v} s0$c_7;

and the lower part

  SR.3_8 = VIEW_CONVERT_EXPR<long long unsigned int>(s0);
  SR.4_9 = SR.3_8 & 0xffffffff00000000;
  SR.5_10 = (long long unsigned int) s0$B0F32_5;
  SR.6_11 = SR.4_9 | SR.5_10;
  s0 ={v} VIEW_CONVERT_EXPR<struct xxx>(SR.6_11);

this is likely because SRA really wants to have two 32bit fields but it
cannot deal with the larger struct with a VIEW_CONVERT_EXPR.

With just disabling all these code-paths we get

<bb 2>:
  s0$B0F32_4 = 0;
  s0$c_5 = p_1(D)->c;
  s0$B0F32_6 = BIT_FIELD_REF <*p_1(D), 32, 0>;
  s0.c ={v} s0$c_5;
  BIT_FIELD_REF <s0, 32, 0> ={v} s0$B0F32_6;
  s ={v} s0;
  s$a_7 = s.a;
  D.1242_2 = s$a_7;

and no warning.  But of course we now have bitfield refs that are not optimized
(not scalarizing in this case would be better).  Of course even with the
current scalarization we finally arrive with

<bb 2>:
  # VUSE <SMT.16_13(D)>
  s0$c_7 = p_1(D)->c;
  # VUSE <SMT.16_13(D)>
  D.1249_4 = VIEW_CONVERT_EXPR<long long unsigned int>(*p_1(D));
  s0$B0F32_5 = (unsigned int) D.1249_4;
  # VUSE <s0_14(D)>
  SR.21_24 = VIEW_CONVERT_EXPR<long long unsigned int>(s0);
  SR.22_25 = SR.21_24 & 0xffffffff00000000;
  # s0_28 = VDEF <s0_14(D)>
  s0 = VIEW_CONVERT_EXPR<struct xxx>(SR.22_25);
  # s0_29 = VDEF <s0_28>
  s0.c = s0$c_7;
  # VUSE <s0_29>
  SR.3_8 = VIEW_CONVERT_EXPR<long long unsigned int>(s0);
  SR.4_9 = SR.3_8 & 0xffffffff00000000;
  SR.5_10 = (long long unsigned int) s0$B0F32_5;
  SR.6_11 = SR.5_10 | SR.4_9;
  s0$B0F32_21 = (unsigned int) SR.6_11;
  s0$c_30 = VIEW_CONVERT_EXPR<struct xxx>(SR.6_11).c;
  # VUSE <s0_29>
  SR.25_31 = VIEW_CONVERT_EXPR<long long unsigned int>(s0);
  SR.26_32 = SR.25_31 & 0xffffffff00000000;
  SR.27_33 = (long long unsigned int) s0$B0F32_21;
  SR.28_34 = SR.27_33 | SR.26_32;
  # s0_35 = VDEF <s0_29>
  s0 = VIEW_CONVERT_EXPR<struct xxx>(SR.28_34);
  # s0_36 = VDEF <s0_35>
  s0.c = s0$c_30;
  # VUSE <s0_36>
  # s_18 = VDEF <s_17(D)>
  s = s0;
  # VUSE <s_18>
  s$a_37 = s.a;
  # s_39 = VDEF <s_18>
  s.a = s$a_37;
  # VUSE <s_39>
  # SMT.16_20 = VDEF <SMT.16_13(D)>
  bar (s);
  return;

because we seem to scalarize again.  Ugh.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (5 preceding siblings ...)
  2008-12-05 12:58 ` rguenth at gcc dot gnu dot org
@ 2008-12-05 13:06 ` rguenth at gcc dot gnu dot org
  2008-12-08 20:35 ` d dot g dot gorbachev at gmail dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-05 13:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2008-12-05 13:05 -------
The following would make SRA only combine all of the struct or nothing.  That
avoids these messy situations:

Index: tree-sra.c
===================================================================
--- tree-sra.c  (revision 142469)
+++ tree-sra.c  (working copy)
@@ -1695,7 +1695,10 @@ try_instantiate_multiple_fields (struct 

   gcc_assert (~alchk < align);

-  /* Create the field group as a single variable.  */
+  /* Create the field group as a single variable if the group covers
+     the whole element.  */
+  if (size != TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (elt->element))))
+    return f;

   /* We used to create a type for the mode above, but size turns
      to be out not of mode-size.  As we need a matching type


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (6 preceding siblings ...)
  2008-12-05 13:06 ` rguenth at gcc dot gnu dot org
@ 2008-12-08 20:35 ` d dot g dot gorbachev at gmail dot com
  2008-12-09 19:36 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2008-12-08 20:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from d dot g dot gorbachev at gmail dot com  2008-12-08 20:34 -------
(In reply to comment #7)

The patch causes segfault. This is how it happens:

tree-sra.c:1612
      for (f = TYPE_FIELDS (elt->type);
           f; f = TREE_CHAIN (f))
        {

tree-sra.c:1700
  if (size != TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (elt->element))))
    return f; // NULL

tree-sra.c:1764
        for (f = TYPE_FIELDS (type); f ; f = TREE_CHAIN (f))
          if (TREE_CODE (f) == FIELD_DECL)
            {
              tree last = try_instantiate_multiple_fields (elt, f);

              if (last != f)
                {
                  f = last;
                  continue;
                }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (7 preceding siblings ...)
  2008-12-08 20:35 ` d dot g dot gorbachev at gmail dot com
@ 2008-12-09 19:36 ` mmitchel at gcc dot gnu dot org
  2008-12-10 17:23 ` aoliva at gcc dot gnu dot org
  2008-12-10 17:37 ` aoliva at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-12-09 19:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (8 preceding siblings ...)
  2008-12-09 19:36 ` mmitchel at gcc dot gnu dot org
@ 2008-12-10 17:23 ` aoliva at gcc dot gnu dot org
  2008-12-10 17:37 ` aoliva at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2008-12-10 17:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from aoliva at gcc dot gnu dot org  2008-12-10 17:22 -------
Subject: Bug 38271

Author: aoliva
Date: Wed Dec 10 17:20:50 2008
New Revision: 142651

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142651
Log:
gcc/ChangeLog:
PR middle-end/38271
* tree-sra.c (sra_build_bf_assignment): Avoid warnings for
variables initialized from SRAed bit fields.
gcc/testsuite/ChangeLog:
PR middle-end/38271
* gcc.dg/torture/pr38271.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr38271.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/38271] [4.4 Regression] Spurious / missing "... used uninitialized in this function" warning
  2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
                   ` (9 preceding siblings ...)
  2008-12-10 17:23 ` aoliva at gcc dot gnu dot org
@ 2008-12-10 17:37 ` aoliva at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2008-12-10 17:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from aoliva at gcc dot gnu dot org  2008-12-10 17:30 -------
Fixed.


-- 

aoliva at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-12-10 17:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-26  2:48 [Bug middle-end/38271] New: Spurious / missing "... used uninitialized in this function" warning d dot g dot gorbachev at gmail dot com
2008-11-26  2:50 ` [Bug middle-end/38271] " d dot g dot gorbachev at gmail dot com
2008-11-26  2:55 ` [Bug middle-end/38271] [4.4 Regression] " pinskia at gcc dot gnu dot org
2008-11-26 10:02 ` rguenth at gcc dot gnu dot org
2008-12-03 16:29 ` jakub at gcc dot gnu dot org
2008-12-03 16:40 ` rguenth at gcc dot gnu dot org
2008-12-05 12:58 ` rguenth at gcc dot gnu dot org
2008-12-05 13:06 ` rguenth at gcc dot gnu dot org
2008-12-08 20:35 ` d dot g dot gorbachev at gmail dot com
2008-12-09 19:36 ` mmitchel at gcc dot gnu dot org
2008-12-10 17:23 ` aoliva at gcc dot gnu dot org
2008-12-10 17:37 ` aoliva at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).