public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members
@ 2005-06-13  8:52 jakub at redhat dot com
  2005-06-13 12:31 ` [Bug tree-optimization/22043] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at redhat dot com @ 2005-06-13  8:52 UTC (permalink / raw)
  To: gcc-bugs

In:
extern void abort (void);

struct A { int i; int j; int k; int l; };
struct B { struct A a; int r[1]; };
struct C { struct A a; int r[0]; };
struct D { struct A a; int r[]; };

void
foo (struct A *x)
{
  if (x->i != 0 || x->j != 5 || x->k != 0 || x->l != 0)
    abort ();
}

int
main ()
{
  struct B b = { .a.j = 5 };
  struct C c = { .a.j = 5 };
  struct D d = { .a.j = 5 };
  foo (&b.a);
  foo (&c.a);
  foo (&d.a);
  return 0;
}

GCC 4.0/HEAD only zero initialize a.i, a.k and a.l for the b variable, not for
c nor d, while 3.4.x and older initialized them for all 3 variables.
This causes miscompilation of glibc by GCC 4.0+.

-- 
           Summary: [4.0/4.1 Regression] Fields not initialized for
                    automatic structs with flexible array members
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at redhat dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug tree-optimization/22043] [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
@ 2005-06-13 12:31 ` pinskia at gcc dot gnu dot org
  2005-06-14 17:08 ` cvs-commit at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-13 12:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-13 12:31 -------
Confirmed, patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-06/msg01103.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |06/msg01103.html
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |patch, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-13 12:31:50
               date|                            |
   Target Milestone|---                         |4.0.1


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


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

* [Bug tree-optimization/22043] [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
  2005-06-13 12:31 ` [Bug tree-optimization/22043] " pinskia at gcc dot gnu dot org
@ 2005-06-14 17:08 ` cvs-commit at gcc dot gnu dot org
  2005-06-23 14:32 ` [Bug tree-optimization/22043] [4.1 " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-14 17:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-14 17:08 -------
Subject: Bug 22043

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	jakub@gcc.gnu.org	2005-06-14 17:08:00

Modified files:
	gcc            : ChangeLog gimplify.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20050613-1.c 

Log message:
	PR tree-optimization/22043
	* gimplify.c (gimplify_init_constructor): If num_type_elements < 0
	for a constant-sized object, set cleared as well.
	
	* gcc.c-torture/execute/20050613-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.287&r2=2.7592.2.288
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.113.2.5&r2=2.113.2.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.238&r2=1.5084.2.239
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20050613-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

* [Bug tree-optimization/22043] [4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
  2005-06-13 12:31 ` [Bug tree-optimization/22043] " pinskia at gcc dot gnu dot org
  2005-06-14 17:08 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-23 14:32 ` pinskia at gcc dot gnu dot org
  2005-07-14 23:17 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-23 14:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-23 14:32 -------
Fixed on the 4.0 branch at least.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.0/4.1 Regression] Fields |[4.1 Regression] Fields not
                   |not initialized for         |initialized for automatic
                   |automatic structs with      |structs with flexible array
                   |flexible array members      |members
   Target Milestone|4.0.1                       |4.1.0


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


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

* [Bug tree-optimization/22043] [4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
                   ` (2 preceding siblings ...)
  2005-06-23 14:32 ` [Bug tree-optimization/22043] [4.1 " pinskia at gcc dot gnu dot org
@ 2005-07-14 23:17 ` steven at gcc dot gnu dot org
  2005-08-22  2:20 ` [Bug middle-end/22043] " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-07-14 23:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-07-14 23:06 -------
Jakub, do you plan to fix this bug on mainline as well?? 

-- 


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


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

* [Bug middle-end/22043] [4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
                   ` (3 preceding siblings ...)
  2005-07-14 23:17 ` steven at gcc dot gnu dot org
@ 2005-08-22  2:20 ` pinskia at gcc dot gnu dot org
  2005-08-23  8:15 ` cvs-commit at gcc dot gnu dot org
  2005-08-23 11:17 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-22  2:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-22 02:20 -------
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg01203.html
contains the lastest patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|http://gcc.gnu.org/ml/gcc-  |http://gcc.gnu.org/ml/gcc-
                   |patches/2005-               |patches/2005-
                   |06/msg01103.html            |06/msg01203.html


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


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

* [Bug middle-end/22043] [4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
                   ` (4 preceding siblings ...)
  2005-08-22  2:20 ` [Bug middle-end/22043] " pinskia at gcc dot gnu dot org
@ 2005-08-23  8:15 ` cvs-commit at gcc dot gnu dot org
  2005-08-23 11:17 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-08-23  8:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-08-23 07:28 -------
Subject: Bug 22043

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jakub@gcc.gnu.org	2005-08-23 07:28:26

Modified files:
	gcc            : ChangeLog expr.c gimplify.c tree-sra.c tree.h 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20050613-1.c 

Log message:
	PR tree-optimization/22043
	* tree.h (count_type_elements): Add ALLOW_FLEXARR argument.
	* expr.c (count_type_elements): Add ALLOW_FLEXARR argument.
	If ALLOW_FLEXARR, handle types ending with flexible array member.
	Pass false as second argument to recursive count_type_elements calls.
	(categorize_ctor_elements_1, mostly_zeros_p): Pass false as second
	argument to count_type_elements call.
	* tree-sra.c (decide_block_copy): Likewise.
	* gimplify.c (gimplify_init_constructor): If num_type_elements < 0
	for a constant-sized object, set cleared as well.  Pass true as
	second argument to count_type_elements call.
	
	* gcc.c-torture/execute/20050613-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9803&r2=2.9804
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.808&r2=1.809
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&r1=2.147&r2=2.148
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-sra.c.diff?cvsroot=gcc&r1=2.70&r2=2.71
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.753&r2=1.754
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5951&r2=1.5952
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20050613-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2



-- 


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


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

* [Bug middle-end/22043] [4.1 Regression] Fields not initialized for automatic structs with flexible array members
  2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
                   ` (5 preceding siblings ...)
  2005-08-23  8:15 ` cvs-commit at gcc dot gnu dot org
@ 2005-08-23 11:17 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-23 11:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-23 11:11 -------
Fixed.

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


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


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

end of thread, other threads:[~2005-08-23 11:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-13  8:52 [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members jakub at redhat dot com
2005-06-13 12:31 ` [Bug tree-optimization/22043] " pinskia at gcc dot gnu dot org
2005-06-14 17:08 ` cvs-commit at gcc dot gnu dot org
2005-06-23 14:32 ` [Bug tree-optimization/22043] [4.1 " pinskia at gcc dot gnu dot org
2005-07-14 23:17 ` steven at gcc dot gnu dot org
2005-08-22  2:20 ` [Bug middle-end/22043] " pinskia at gcc dot gnu dot org
2005-08-23  8:15 ` cvs-commit at gcc dot gnu dot org
2005-08-23 11:17 ` pinskia 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).