From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22016 invoked by alias); 4 Oct 2018 12:40:00 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 22006 invoked by uid 89); 4 Oct 2018 12:39:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KAM_SHORT,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*M:1621 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Oct 2018 12:39:58 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 217263084026; Thu, 4 Oct 2018 12:39:57 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 483FF2CFFB; Thu, 4 Oct 2018 12:39:56 +0000 (UTC) Subject: Re: gcc warning with "some variable may be used uninitialized in this function [-Wmaybe-uninitialized]" when building under msys To: Simon Marchi , asmwarrior References: <46b498a8-ba44-3f67-783d-85cd5ac8f0c9@gmail.com> <9aa0ec3d6356d1e0c746697161918576@polymtl.ca> Cc: GDB Development From: Pedro Alves Message-ID: <8305e255-1621-96a7-cf06-3cd1cd27ceae@redhat.com> Date: Thu, 04 Oct 2018 12:40:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <9aa0ec3d6356d1e0c746697161918576@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-10/txt/msg00002.txt.bz2 On 10/04/2018 01:00 PM, Simon Marchi wrote: > On 2018-10-04 02:28, asmwarrior wrote: >> Hi, when building gdb git head(which is >> 875e539851bb2702f3292f819e220545a8776242 as 2018-10-04) under msys+gcc >> 5.4, I see such warning: >> >>   CXX    infrun.o >> In file included from ../../binutils-gdb/gdb/inferior.h:49:0, >>                  from ../../binutils-gdb/gdb/infrun.c:26: >> ../../binutils-gdb/gdb/progspace.h: In function 'void >> handle_vfork_child_exec_or_exit(int)': >> ../../binutils-gdb/gdb/progspace.h:285:47: warning: '*((void*)(& >> maybe_restore_inferior)+16).scoped_restore_current_program_space::m_saved_pspace' >> may be used uninitialized in this function [-Wmaybe-uninitialized] >>    { set_current_program_space (m_saved_pspace); } >>                                                ^ >> ../../binutils-gdb/gdb/infrun.c:931:6: note: '*((void*)(& >> maybe_restore_inferior)+16).scoped_restore_current_program_space::m_saved_pspace' >> was declared here >>       maybe_restore_inferior; >>       ^ >>   CXX    inline-frame.o >> >> Hope you devs can fix this. Thanks. >> >> Asmwarrior > > I also see this from time to time.  I think it is a false positive, but I may be wrong.  Do you see a code path that could actually be problematic? That warning is documented as producing false positives. And those preexisting warnings are hard/ugly to disable with #pragma GCC diagnostic push/pop. That's why we disable -Werror for that warning. There's been mild talking about moving -Wmaybe-uninitialized out of -Wall in gcc, which I think would make sense. Over time, GCC's VRP etc. technology will improve and those same bugs will be warned by -Wuninitialized instead (I'd hope). See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 If the warnings confuse people too much, I'd be OK with disabling -Wmaybe-uninitlized completely. I left it as a -Wno-error warning because even though it produces false positives, it also helps catch bugs earlier in the compile-edit cycle, when you're hacking some code, when you're introducing uninitialized uses, and "make" ends up compiling just a few files. Thanks, Pedro Alves