From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 8617D3858001 for ; Thu, 2 Dec 2021 20:31:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8617D3858001 Received: by mail-wm1-x32a.google.com with SMTP id i12so709387wmq.4 for ; Thu, 02 Dec 2021 12:31:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=OHZYX8sQJfGuGBHMVnsTpA4eAKb6K3NaRgynnKjlfAo=; b=TrMuNuJBAr5D55Xqt+PQZUIZtISxUgJZg/5BNBfXpeG0zZDmB878Ew3Chj8EU4t0qN 90MANn90/Qlu09Y3wWskpg+IUKFMXG/iMPaE4uZ/6VqTOQdRmZQ0b5wqEI5h5MiZ/t7k B9bRlb8kI7lDiekzl9sGTadz1QK77tALnN089jaXKb1Rceyfld5YcmTqK7V9dLZA2tae 8zPNVH+WvtHYGAN2zQw8AeX5pGvyklyDKC093DpSHBPAYder5hM8ZyFrwN65K0Z7enqB EfulC445JsQwJMJWEwQNlO/pBP/9xb43YFwwrI79nJEocaN/t3w6kH9R+XwE6T1rtm2g 6Lyg== X-Gm-Message-State: AOAM532MCkLvw4mKxem6+8aSgDxAAbdzjgrHR++SLuN3ishk2qMlEFNu jlpr73pnQE8MCf7eNUY3SIE= X-Google-Smtp-Source: ABdhPJwxiKFIWJ+u26bPUH9yr26kVUP1Gy+6B4yziK66fjiB5CJyzcwj2aHyHDcqn8t2iA1cAqt6TA== X-Received: by 2002:a05:600c:296:: with SMTP id 22mr9353759wmk.135.1638477104580; Thu, 02 Dec 2021 12:31:44 -0800 (PST) Received: from [10.168.10.170] ([170.253.36.171]) by smtp.gmail.com with ESMTPSA id z18sm732739wrq.11.2021.12.02.12.31.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Dec 2021 12:31:44 -0800 (PST) Sender: Alejandro Colomar Message-ID: <03338dbf-878d-2910-c676-b0945a61a10d@gmail.com> Date: Thu, 2 Dec 2021 21:31:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: ISO C3X proposal: nonnull qualifier Content-Language: en-US From: "Alejandro Colomar (man-pages)" To: Joseph Myers Cc: gcc@gcc.gnu.org, cfe-dev@lists.llvm.org References: <56a1a945-608e-0e5e-7610-c35481abb980@gmail.com> <4883fa8c-2d99-2611-a8e2-6c7612283da4@gmail.com> <3178a917-e9df-36eb-4382-f8aec7b678a2@gmail.com> In-Reply-To: <3178a917-e9df-36eb-4382-f8aec7b678a2@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 20:31:49 -0000 On 12/2/21 21:24, Alejandro Colomar (man-pages) wrote: > >     #define nonnull_assign(nn, p)                         \ >     ({                                                    \ >         auto p_  = p;                                 \ >         auto nn_ = nn;                                \ >                                                               \ >         if (p_ == NULL)                               \ >             *nn_ = const_cast(typeof(nn_), p_);  \ D'oh, this check should be the opposite, of course :) >                                                               \ >         p_ == NULL;                                   \ >     }) > And I forgot to mention, that this macro intentionally leaves the nonnull pointer (nn) uninitialized in the case of a NULL input pointer (p), so that the compiler can then warn about an uninitialized variable if it's used uninitialized. Cheers, Alex -- Alejandro Colomar Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/