From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32565 invoked by alias); 18 Nov 2014 23:01:17 -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 32543 invoked by uid 48); 18 Nov 2014 23:01:13 -0000 From: "eggert at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/63943] New: -Wmaybe-uninitialized pragma mishandled in inlined function Date: Tue, 18 Nov 2014 23:01: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.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at gnu dot org X-Bugzilla-Status: UNCONFIRMED 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 attachments.created Message-ID: 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-11/txt/msg01783.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63943 Bug ID: 63943 Summary: -Wmaybe-uninitialized pragma mishandled in inlined function Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: eggert at gnu dot org Created attachment 34031 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34031&action=edit Program with -Wmaybe-uninitialized problem Compile the attached program t.c with "gcc -Wmaybe-uninitialized -O2 -c t.c" on x86-64 with GCC 4.9.2, and the output will be: t.c: In function 'main': t.c:17:3: warning: '*((void *)&v+4)' may be used uninitialized in this function [-Wmaybe-uninitialized] return argc < 1 ? !argv : dereference (v + 1); ^ '#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"' is in effect when the possibly-uninitialized variable is used, but this use is in a function that GCC inlined, and GCC is incorrectly warning based on the pragma setting in the calling function, not based on the pragma setting where the dereferencing actually occurs. The problem does not occur with GCC 4.8.3 so this appears to be a regression. The problem also goes away if I add '__attribute__((noinline))' to the 'dereference' function, so this appears to be related to inlining. I ran into this problem while thinking about enabling -Werror when compiling glibc; my first cut at this ran into the above problem.