From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 73CF93858C1F for ; Tue, 30 May 2023 09:07:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73CF93858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3980f2df1e7so2407771b6e.1 for ; Tue, 30 May 2023 02:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685437676; x=1688029676; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L7UBy5ImbS5tx+OMVK3ROLf07bbnglP9G/MJkkkANPA=; b=UJCAt+TDN+B76BY4QBE8AEDdNz/m6TyKxLIW1dDeecNwct6Wwfj9csnkS+8w+rVNnY DvA8GQetOFqgZoV+pvXF7thBbqCo2ukBVsIG+EC4GZSG+GZlPrq/flpB2VG/s29YY+xV SAsqHC3SaYlqRuwiUTNByDgUckv0FzugBKsdDIF3M5MZFdoN+0GM3tI4lrKNBzDd2OYO PVGP0KzLfreL8oHpbK7nlSeXOC7gieel/FxJiqQyf3YAOOR/OoCN/VV7bdXXZwdlmo46 Yn0fYRtl7Cu/42g34QarBdwq6RiAWLA3KE/dLmD4YZbLVnCPCIPdqeAxGaTOJb82zv2e Wx5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685437676; x=1688029676; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L7UBy5ImbS5tx+OMVK3ROLf07bbnglP9G/MJkkkANPA=; b=HrwDnwXRcTBYV+jNkt4UtNZhLSc9pqlIzXtaMYrR+oxdiCEfGjRVqiv9F/INwv8nyR T0MJzU1a+sv24bxr0BFYm9PR3bulrFldfLfUuTEo3sFJqXrH8+5Vg9CAqEl8eeoXes8L mty2ffNy5jDbo5j7DKdWHdnoxo/uVKm8DnWAkN/xXwDgtFpuk3axX2qaSAXl766KXeZw OetrxCszxsU7Xfe/0NAFfRPjSf+8zFRt0xTpT4PV0A5wfVI4D0wD2RG7ZgQlMpfulIot uBOelZFJ3KGI6vOAqYnWHRXD38GlAWkINvJVIwdGLRvQ4cUYWFy4Gfu6QP5FNn1eT2MG 7LLQ== X-Gm-Message-State: AC+VfDzOolno7a/BSCzzu6tuD8UyTM6fTHtpT/l/2RPljZDG/AD/9sFS H9SuZ+/sQg16l6/1MoRiGwpjScRMvAIM7TKWQN0= X-Google-Smtp-Source: ACHHUZ6Lh3deA6Mm2uoqXZuG4sHiMuVkSAkRGHj2URm10JtlCoEEFPeYM6TKKptJUsjqHDG87jQpj4PWrmufGHxfoPg= X-Received: by 2002:a05:6808:1496:b0:398:2f85:ff7f with SMTP id e22-20020a056808149600b003982f85ff7fmr1296886oiw.50.1685437675605; Tue, 30 May 2023 02:07:55 -0700 (PDT) MIME-Version: 1.0 References: <20230528172013.73111-1-bugaevc@gmail.com> <20230528172013.73111-4-bugaevc@gmail.com> <31457dbb-a805-262f-4b62-be0b40960ca6@linaro.org> <8354c659-cfb0-993a-2764-72a2cd6f6ed4@linaro.org> <87edmyxo4p.fsf@oldenburg.str.redhat.com> In-Reply-To: <87edmyxo4p.fsf@oldenburg.str.redhat.com> From: Sergey Bugaev Date: Tue, 30 May 2023 12:07:44 +0300 Message-ID: Subject: Re: [PATCH v2 3/3] io: Add FORTIFY_SOURCE check for fcntl arguments To: Florian Weimer Cc: Adhemerval Zanella Netto , libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, On Tue, May 30, 2023 at 10:41=E2=80=AFAM Florian Weimer wrote: > The noinline attribute does exactly what it says: it prevents inlining, > but it does not prevent inter-procedural analysis. So if a function > returns a constrant, the compiler will still use that constant > elsewhere. Newer GCC versions support the noipa attribute. If you drop > the static, you can use the weak attribute for compatibility with pretty > much all GCC versions. > > But I think using volatile (without noinline for clarity) is fine here. So do I read this right that you're saying I should just do static int hide_constant (int value) { volatile int v =3D value; return v; } ? After the yesterday's discussion with Adhemerval, I was thinking of doing static inline int hide_constant (int value) { asm ("" : "+rm" (value)); return value; } This does *not* prevent the whole computation from being optimized out if the result is unused (i.e. there's no 'volatile'), but it does prevent the compiler from assuming anything about the return value. > > My guess is because template with extern "C" are not really supported i= n all > > configurations. > > It's possible to use extern "C++" around the template. I didn't realize it was possible to nest the extern "..." { } blocks, thank= you. Sergey