From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DFC953877024; Mon, 16 Mar 2020 16:54:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFC953877024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584377674; bh=pMxQ3w3oAt4o61xZIJE8A/BBuVI1SOHOCKDUxtMgexk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KykJO1b4wlzo7tvvVz3QikQftW4go1GE6X1Z90FtfG/CwHGn6kURefNxd0kNsxEIF qYQ24qEmvs2vxJDl8WNthUBBsnY4eT/3EXUNr6S1Eev595acciaVyXIczYy3n+pK2t VFVjNTqXAT2cpMYVj+YR3BM1KO04RPLl4BHxve9U= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/90404] No warning on attempts to modify a const object Date: Mon, 16 Mar 2020 16:54:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 9.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: target_milestone component Message-ID: In-Reply-To: References: 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-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 16:54:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D90404 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |11.0 Component|c |middle-end --- Comment #4 from Martin Sebor --- No progress for GCC 10. I plan to work on it for GCC 11. Here's a test case where the fact that the modification is invalid is less obvious and doesn't trigger a warning. The dump shows how the code emitted= by GCC makes assumptions that make the undefined behavior manifest without ever causing the program to crash at runtime. $ cat x.C && gcc -O2 -S -Wall -Wextra -Wcast-qual -Wpedantic -fdump-tree-optimized=3D/dev/stdout x.C const char a[] =3D "012.45"; int f (void) { char *p =3D __builtin_strchr (a, '.'); *p =3D 0; if (__builtin_strlen (p) !=3D 3) // folded to false __builtin_abort (); return a[3] =3D=3D 0; // also folded to false } ;; Function f (_Z1fv, funcdef_no=3D0, decl_uid=3D2328, cgraph_uid=3D1, symbol_order=3D1) f () { [local count: 1073741824]: return 0; }=