From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id D41F73852207 for ; Mon, 12 Dec 2022 18:16:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D41F73852207 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 2BCIFDpq004813; Mon, 12 Dec 2022 12:15:13 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 2BCIFCiQ004812; Mon, 12 Dec 2022 12:15:12 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 12 Dec 2022 12:15:12 -0600 From: Segher Boessenkool To: Richard Biener Cc: Adhemerval Zanella , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] longlong.h: Do no use asm input cast for clang Message-ID: <20221212181512.GE25951@gate.crashing.org> References: <20221130181625.2011166-1-adhemerval.zanella@linaro.org> <20221130232456.GT25951@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! On Thu, Dec 01, 2022 at 08:26:52AM +0100, Richard Biener wrote: > On Thu, Dec 1, 2022 at 12:26 AM Segher Boessenkool > wrote: > > On Wed, Nov 30, 2022 at 03:16:25PM -0300, Adhemerval Zanella via Gcc-patches wrote: > > > clang by default rejects the input casts with: > > > > > > error: invalid use of a cast in a inline asm context requiring an > > > lvalue: remove the cast or build with -fheinous-gnu-extensions > > > > > > And even with -fheinous-gnu-extensions clang still throws an warning > > > and also states that this option might be removed in the future. > > > For gcc the cast are still useful somewhat [1], so just remove it > > > clang is used. > > > > This is one of the things in inline asm that is tightly tied to GCC > > internals. You should emulate GCC's behaviour faithfully if you want > > to claim you implement the inline asm GNU C extension. > > I understand that the casts should be no-ops on the asm side (maybe they > change the sign) and they are present as type-checking. Can we implement > this type-checking in a different (portable) way? Portable? Portable between which things? Inline assembler is a GNU C extension, this is portable between any two compilers that implement that (correctly), already. This can be written some other way of course, but as I said before, most instances of longlong.h that are used "in the wild" are over ten years old, so we really cannot fix that "problem". If we would distribute this header with GCC, then we could start doing such things as soon as people start using the new header. But almost all of the functionality the header provides is legacy anyway! > I think the macro you use > should be named like __asm_output_check_type (..) or so to indicate the > intended purpose. I'm all for that, certainly. Or a better name preferably (check type for what? And do what with the result? Etc.) Segher