From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8436EC43334 for ; Tue, 14 Jun 2022 22:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354575AbiFNWI5 (ORCPT ); Tue, 14 Jun 2022 18:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358426AbiFNWIz (ORCPT ); Tue, 14 Jun 2022 18:08:55 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E17FF4F47D for ; Tue, 14 Jun 2022 15:08:52 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id p128so10905643iof.1 for ; Tue, 14 Jun 2022 15:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4dGwyqQWqKQhUVZXocdLXxbcz5iYcIebggOB8F+Krxg=; b=FMnyQsbBTpfaI982a6MQ8uP9ByA2o3U8F3mrkPUXG5pAZOzw98y0CapM11N8zUSG0t 99K7QlRSow8lJ80bPLWSV5/BAgHq/LkEyuiWY8Z5wDHKVa42NKERpzSJzXuvOlA7ZgtE PxlpozmA+LusYvnX5clXnPKnxVgZ/njUZPiWCIrJkhuGEkvmeeNlfHMHPyoLZGI7ljXB 5d/9uZc5/9VAjp90jGCddlIt3tzsIzRkKWeHDudrnFvSmA+kUcVneI4x7FaSLKVfHR+t Lgq9/jNX/HxyW+K50bQGutQLKTOcIxdU2M1Zx7BDWn2VLhxHEPBklp1eztS5pV776hHS x0PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4dGwyqQWqKQhUVZXocdLXxbcz5iYcIebggOB8F+Krxg=; b=16wg+J/iKUIL+HblKtnGRx8a9IQOs0jQb9vhX/nirXolzsxPjHU6eFPgCqwPEkLOPM U+OKyNT70sp9FlFgjMs1Sh160TVICcZiijY6nM+9wABKLX5mp8cq70nanas1EJwe1AHp Nw5rOlnDyw0ZaODOHMrJgyrt8lFazjIbqqs4hikxPM0jTMlG+5BE4MSm9y9GUD9n8moX I9E+RthBXEsjUsoxg5osWvtCdcKW7SDFs5htqcRcSSERGJ0HFyqTbqBHW+7xfNr5NfBp iY78f7MFmc/NPs8X3LGGxhVz1//SfswRdOf9ZvUb51XEAaTu6Otey6365vTYWEhthHCj uEjg== X-Gm-Message-State: AOAM532X/qlT8No7ak6CtFe1UdlygV+9/ML2H+8RC7z5hpze8IuMKxtN md4GufCedEHm8KnfyBML7K6EFwiUaQmQiNGJdY8NoA== X-Google-Smtp-Source: ABdhPJxXo8qyCxQNbUKgcqR58bxEuX/+dZOP2labZ9vMu4YcVrmdVsOc+ZJkU8X5BYEfYIw3TbCfn9YQ3wJcMy9Tkfs= X-Received: by 2002:a02:a98a:0:b0:332:b171:df78 with SMTP id q10-20020a02a98a000000b00332b171df78mr4035478jam.54.1655244531923; Tue, 14 Jun 2022 15:08:51 -0700 (PDT) MIME-Version: 1.0 References: <20220614144853.3693273-1-glider@google.com> <20220614214039.GA25951@gate.crashing.org> In-Reply-To: <20220614214039.GA25951@gate.crashing.org> From: Evgenii Stepanov Date: Tue, 14 Jun 2022 15:08:40 -0700 Message-ID: Subject: Re: [PATCH] [RFC] Initialization of unused function parameters To: Segher Boessenkool Cc: Alexander Potapenko , Linus Torvalds , Kees Cook , Marco Elver , Nathan Chancellor , Nick Desaulniers , Thomas Gleixner , Vitaly Buka , Linux Kernel Mailing List , linux-toolchains Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Tue, Jun 14, 2022 at 2:45 PM Segher Boessenkool wrote: > No such luck: the passing itself already causes UB. > > GCC does not warn, it has already optimised the code to what you expect > by the time this warning is done. If you use -fno-inline it does warn > for both "c" and "size" (via -Wmaybe-uninitialized). > > But it is still UB! All bets are off, no compiler can do any correct > translation of your program, since there *is none*. Clang also puts "noundef" attribute on most function arguments in the frontend, and the optimizer can assume that the inputs are fully initialized. The diagnostic for this is very imperfect. What Alex is proposing (the KMSAN option) takes place *after* inlining, so it will only enforce the "semantically meaningful" case in Linus's words.