From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gandi.kataplop.net (gandi.kataplop.net [46.226.111.114]) by sourceware.org (Postfix) with ESMTPS id C2B73388A409 for ; Tue, 29 Jun 2021 06:29:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C2B73388A409 Received: from [176.191.105.132] (helo=arrakis) by gandi.kataplop.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ly7Ey-0007D9-Sn; Tue, 29 Jun 2021 08:29:01 +0200 From: Marc To: Mark Wielaard Cc: Marc , gcc-rust@gcc.gnu.org Subject: Re: [PATCH] Suppress warning in rust-ast-lower-type.h ASTLowerGenericParam.visit. References: <20210628214147.256049-1-mark@klomp.org> <87pmw53apr.fsf@arrakis.kataplop.net> Date: Tue, 29 Jun 2021 08:28:51 +0200 In-Reply-To: (Mark Wielaard's message of "Tue, 29 Jun 2021 01:41:43 +0200") Message-ID: <87lf6t2nh8.fsf@arrakis.kataplop.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam_score: -1.0 X-Spam_bar: - X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, 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: Tue, 29 Jun 2021 06:29:09 -0000 Mark Wielaard writes: > 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, >> >=20 >> > > Translating the AST LifetimeType to the HIR LifetimeType causes a wa= rning: >> > > warning: =E2=80=98ltt=E2=80=99 may be used uninitialized >> >=20 >> > 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 b= ut >> > was thinking something else was causing the error... >>=20 >> 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. I thought maybe that's a C++ vs C diff, or something caused by the Lifetime being returned by a function call, but I can't reproduce it, so that must be something else: https://godbolt.org/z/sjbcWEqdj Anyway, Philipp wants to have these enum shared between AST and HIR, so this kind of 'if(AST::Foo) t=3DHIR::Foo' can be removed. I'm still curious about why the warning is raised in this case... Marc