From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1947 invoked by alias); 28 Oct 2004 14:19:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1927 invoked by uid 48); 28 Oct 2004 14:19:51 -0000 Date: Thu, 28 Oct 2004 14:19:00 -0000 Message-ID: <20041028141951.1926.qmail@sourceware.org> From: "pinskia at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041028081035.18191.grigory.zagorodnev@intel.com> References: <20041028081035.18191.grigory.zagorodnev@intel.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug middle-end/18191] [4.0 Regression] Struct member is not getting default-initialized X-Bugzilla-Reason: CC X-SW-Source: 2004-10/txt/msg03483.txt.bz2 List-Id: ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-28 14:19 ------- Confirmed, a regression but I don't know if this is a middle-end problem or a front-end problem. The front-end produces the following code: struct S obj[2] = {{.s=(const char *) "m0"}, {}}; This is a middle-end (the gimplifier) issue as the C front-end has the same problem (the C standard defines it in 6.7.8/21). The C example: #include typedef struct S { const char* s; int i; } S; void foo() { // Put some garbage on the stack S dummy[2]; for (unsigned i = 0; i < sizeof(dummy); i++) ((char *)&dummy)[i] = -1; } int bar() { // Allocate object on the stack S obj[2] = { {"m0"}, { } }; // Assume fields those not explicitly initialized // are default initialized to 0 [8.5.1/7 and 8.5/5] if (obj[0].i == 0){ return 0; } else { printf("Failed: obj[0].i == '%d', expecting '0'\n", obj[0].i); return 1; } }; int main(){ foo(); return bar(); } Note we get a warning which is bogus: pr18191.c:23: warning: 'obj$0$i' is used uninitialized in this function -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Component|c++ |middle-end Ever Confirmed| |1 Keywords| |wrong-code Last reconfirmed|0000-00-00 00:00:00 |2004-10-28 14:19:42 date| | Summary|Struct member is not getting|[4.0 Regression] Struct |default-initialized |member is not getting | |default-initialized Target Milestone|--- |4.0.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18191