From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25296 invoked by alias); 19 Aug 2015 19:33: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 17048 invoked by uid 55); 19 Aug 2015 19:33:08 -0000 From: "zeccav at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/67279] -fsanitize=undefined spurious error: initializer element is not constant Date: Wed, 19 Aug 2015 19:33: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: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zeccav 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: 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-08/txt/msg01366.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67279 --- Comment #3 from Vittorio Zecca --- The following code has UB at lines 4 and 5 but compiles with -fsanitize=undefined int main() { int test[1],t; t=test[1]; return test[1]; } Its execution it delivers four runtime errors from the sanitizer and I am happy with that ps.c:4:7: runtime error: index 1 out of bounds for type 'int [1]' ps.c:4:2: runtime error: load of address 0x7ffcb21195f4 with insufficient space for an object of type 'int' 0x7ffcb21195f4: note: pointer points here e0 96 11 b2 fc 7f 00 00 00 00 00 00 00 00 00 00 70 07 40 00 00 00 00 00 e0 ff a1 0d 39 00 00 00 ^ ps.c:5:12: runtime error: index 1 out of bounds for type 'int [1]' ps.c:5:8: runtime error: load of address 0x7ffcb21195f4 with insufficient space for an object of type 'int' 0x7ffcb21195f4: note: pointer points here e0 96 11 b2 fc 7f 00 00 00 00 00 00 fc 7f 00 00 70 07 40 00 00 00 00 00 e0 ff a1 0d 39 00 00 00 In short: I like to see gcc -fsanitize=undefined to compile codes it compiles without sanitation