From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2398 invoked by alias); 11 Sep 2014 22:26:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2368 invoked by uid 48); 11 Sep 2014 22:26:11 -0000 From: "leis at in dot tum.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/63233] Missing Warray-bounds warning for array within struct Date: Thu, 11 Sep 2014 22:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: major X-Bugzilla-Who: leis at in dot tum.de X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-09/txt/msg01464.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63233 --- Comment #5 from leis at in dot tum.de --- Thanks. I did notice that I get warning with optimization but not without, which is strange indeed. However, obviously my real problem is more complicated, and I'm trying to understand if I violate the standard. If I pick apart the offending line (foo.a[1] = 99;): int* p1 = foo.a; //1 int* p2 = p1 + 1; //2 *p2 = 99; //3 Which of these lines causes the undefined behavior? Why should pointer p2 be invalid? Fundamentally, what I'm really trying to do, is to have two arrays (of different types) in a fixed-sized struct. One array grows from the front, and one from the end. Dynamically I make sure that they do not overlap, but the sizes of the two arrays are not known statically. Is it really violating the standard?