From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108253 invoked by alias); 21 Jun 2015 21:09:39 -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 108206 invoked by uid 48); 21 Jun 2015 21:09:36 -0000 From: "Keith.S.Thompson at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66618] New: Failure to diagnose non-constant initializer for static object with -O1 Date: Sun, 21 Jun 2015 21:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.8.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Keith.S.Thompson at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg01862.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66618 Bug ID: 66618 Summary: Failure to diagnose non-constant initializer for static object with -O1 Product: gcc Version: 4.8.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: Keith.S.Thompson at gmail dot com Target Milestone: --- $ uname -a Linux m5 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_= 64 x86_64 x86_64 GNU/Linux $ gcc --version | head -n 1 gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 $ cat bug.c int main(void) { const int not_a_constant =3D 0; static int n =3D not_a_constant; /* constraint violation */ return n; /* avoid unused variable warning */ } $ gcc -O0 -c -std=3Dc11 -pedantic-errors -Wall -Wextra bug.c bug.c: In function =E2=80=98main=E2=80=99: bug.c:3:5: error: initializer element is not constant static int n =3D not_a_constant; /* constraint violation */ ^ $ gcc -O1 -c -std=3Dc11 -pedantic-errors -Wall -Wextra bug.c $=20 In the test program "bug.c", the object "not_a_constant" is defined as "con= st", but its name is not a constant expression. The initializer for a static expression must be a constant expression; using a non-constant expression i= s a constraint violation, requiring a diagnostic (N1570 6.7.9p4). With "-O0", gcc correctly diagnoses this. I see the same problem with "-O1", "-O2", and "-O3", and with "-std=3Dc90", "-std=3Dc99", and "-std=3Dc11". This is based on a question posted to Stack Overflow: http://stackoverflow.com/q/30962512/827263 by user "meet". Grzegorz Szpetkowski gets the credit for realizing that the "-O" option triggers the bug. >>From gcc-bugs-return-489531-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jun 21 21:10:49 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 109229 invoked by alias); 21 Jun 2015 21:10:49 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 109198 invoked by uid 48); 21 Jun 2015 21:10:45 -0000 From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/66578] [F2008] Invalid free on allocate(...,source=a(:)) in block Date: Sun, 21 Jun 2015 21:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: vehre 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: 2015-06/txt/msg01863.txt.bz2 Content-length: 357 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66578 --- Comment #15 from Thomas Koenig --- Is this something which could also have caused wrong-code issues in other circumstances, which we just didn't happen to find until this was exposed by Andre's patch and the test case? In other words, should we backport Mikael's patch?