From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92884 invoked by alias); 9 Oct 2018 20:01:30 -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 92554 invoked by uid 89); 9 Oct 2018 20:01:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=payload 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; Tue, 09 Oct 2018 20:01:11 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30D8A3083392; Tue, 9 Oct 2018 20:01:00 +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 DCFE765F53; Tue, 9 Oct 2018 20:00:58 +0000 (UTC) Subject: Re: gcc warning with "some variable may be used uninitialized in this function [-Wmaybe-uninitialized]" when building under msys To: Tom Tromey References: <46b498a8-ba44-3f67-783d-85cd5ac8f0c9@gmail.com> <9aa0ec3d6356d1e0c746697161918576@polymtl.ca> <8305e255-1621-96a7-cf06-3cd1cd27ceae@redhat.com> <87d0spf0au.fsf@tromey.com> <878t36gbix.fsf@tromey.com> <52ef21f6-8129-2f0e-9510-8e6545d2f2e8@redhat.com> Cc: Simon Marchi , asmwarrior , GDB Development From: Pedro Alves Message-ID: <6b1f8652-a44f-a4d1-6497-3d9a1cfdc3cf@redhat.com> Date: Tue, 09 Oct 2018 20:01: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: <52ef21f6-8129-2f0e-9510-8e6545d2f2e8@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-10/txt/msg00014.txt.bz2 On 10/09/2018 08:54 PM, Pedro Alves wrote: > On 10/09/2018 08:33 PM, Tom Tromey wrote: >>>>>>> "Pedro" == Pedro Alves writes: >> >>>> It would be good if gcc could recognize std::optional and not issue the >>>> warning when it is used. Perhaps gdb could then just always use >>>> optional for the maybe-not-initialized cases. >> >> Pedro> Really not sure whether that is possible. I think there's hope >> Pedro> that GCC value tracking becomes smart enough that these >> Pedro> std::optional-related warnings end up disappearing (which usually >> Pedro> means the code will optimize better too). Fingers crossed, at least. >> >> For gdb::optional, I think it would be good enough if we could simply >> suppress the warning and make operator* assert that the object was >> instantiated. Perhaps std::optional could enforce this in debug mode as >> well. > > Last I tried, I couldn't find a way to suppress the warning from > gdb::optional. The warning triggers in code that belongs to > T in gdb::optional. Maybe we could make gdb::optional's ctor initialize the payload only in devel mode, leave it uninitialized in release mode, and add back -Werror for that warning. We'd see the warnings in release mode, but releases don't use -Werror so it's less of an issue. Doesn't really fix the issue though, just papers over it. Not sure that really helps. Thanks, Pedro Alves