From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 6D79D3857C5F for ; Mon, 28 Jun 2021 23:41:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D79D3857C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x0c.wildebeest.org [172.31.17.142]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id EFB1E300EBD0; Tue, 29 Jun 2021 01:41:43 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id BC35D2E80146; Tue, 29 Jun 2021 01:41:43 +0200 (CEST) Date: Tue, 29 Jun 2021 01:41:43 +0200 From: Mark Wielaard To: Marc Cc: gcc-rust@gcc.gnu.org Subject: Re: [PATCH] Suppress warning in rust-ast-lower-type.h ASTLowerGenericParam.visit. Message-ID: References: <20210628214147.256049-1-mark@klomp.org> <87pmw53apr.fsf@arrakis.kataplop.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-rust@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: gcc-rust mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2021 23:41:46 -0000 On Tue, Jun 29, 2021 at 12:47:07AM +0200, Mark Wielaard wrote: > On Tue, Jun 29, 2021 at 12:06:56AM +0200, Marc wrote: > > Hi, > > > > > Translating the AST LifetimeType to the HIR LifetimeType causes a warning: > > > warning: ‘ltt’ may be used uninitialized > > > > Was wondering why this is needed as the switch case covers all enum > > variants, how can ltt be uninitialized ? I have the same fix locally but > > was thinking something else was causing the error... > > LifetimeType is a plain enum, which aren't really their own types, > they are really just ints with fancy names. We could make them enum > class, which is a strong type. Then the compiler would know the switch > really covers all enum (class) variants. But then we have to provide > the right scope/type everywhere we use them in the code (which might > be a good idea, but is more typing). I just tried to make LifetimeType an enum class and that doesn't help. So I was wrong. I don't know why the compiler doesn't see this? It should know since if not all switch cases were covered, -Wswitch (enabled by -Wall) gives us a warning... So, I don't fully understand why gcc needs the default gcc_unreachable case. It is what is used in the rest of the code though. Cheers, Mark