From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 663CC3858410 for ; Wed, 17 Nov 2021 00:06:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 663CC3858410 Received: by mail-wr1-x42b.google.com with SMTP id b12so1025361wrh.4 for ; Tue, 16 Nov 2021 16:06:15 -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:cc:references:to:in-reply-to :content-transfer-encoding; bh=m90KZiiwGoCIiDIf4ohO6bmmpKMjteu3lQgyKGW9IhI=; b=4NwYxejUf6IBWBoBy29TuJIJULOLGhp8WiVSx02+mVKXouOsHESXBKmaMCqbHAFnJg HAmRhmNTZXsYPQ0oVX6OZCUTWI7nukbU4Sn/+aZo4+3jLnBs6/dgBB9KDp/D+JHMJO02 c7kSA7Ro3txcjn3GZtErtPcA5R9TQyU0vqE6+mx0lXemOyH8SxzdBXu22R3D4RVkWnM6 2HIvlhD2NcN3mvcYIgZxF0WwDI9zlzg7IS7KIRiNqDR/3tdUTJeBq0iGPf0blhtcV6JE iiRlvl2Vv/EKE0krutQe5616bT38xfyc/kRuIdSotneErGlLldNL9tuyI2HVWivAAwVo 5H/g== X-Gm-Message-State: AOAM533bgfCoKpiK5A3mBTAUQBMaXu4SYmnp97hk/oXMfpOhNC+xnmv6 rdjR4/AfPEhzqa+hKRa3mb4= X-Google-Smtp-Source: ABdhPJxyjYDZA2Gl6wmYtPd/e3lnOgL6JyccVyaMeeZyGof3safvIrn/JHH38qeU5uy55YQR/VSdnA== X-Received: by 2002:a5d:59aa:: with SMTP id p10mr14215281wrr.210.1637107574316; Tue, 16 Nov 2021 16:06:14 -0800 (PST) Received: from [10.168.10.170] ([170.253.36.171]) by smtp.gmail.com with ESMTPSA id ay21sm4002449wmb.7.2021.11.16.16.06.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Nov 2021 16:06:13 -0800 (PST) Sender: Alejandro Colomar Message-ID: <79b4ef92-38a9-b8ba-6259-f8ade53880ca@gmail.com> Date: Wed, 17 Nov 2021 01:06:12 +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)" Cc: gcc@gcc.gnu.org, Joseph Myers References: <56a1a945-608e-0e5e-7610-c35481abb980@gmail.com> <4883fa8c-2d99-2611-a8e2-6c7612283da4@gmail.com> To: cfe-dev@lists.llvm.org In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, 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: Wed, 17 Nov 2021 00:06:17 -0000 Hi, Sorry for Clang people, when I started this thread, I wasn't subscribed to your list, and some messages are not on your list. You can find the complete thread on the GCC list: I have a few questions for you. See below, please. On 11/16/21 13:34, Alejandro Colomar (man-pages) wrote: > $ cat _Nonnull.c > #include > > int *_Nonnull f(int *_Nullable p) > { >     if (!p) >         exit(1); >     return p; > } > > > - I get a warning from f(). >   Ideally, >   a programmer should not need to cast >   (casts are dangerous), >   to convert a nullable pointer to a _Nonnull pointer. >   For that, >   appropriate checks should be in the preceeding code. >   Otherwise, a diagnostic should be issued. >   To be on the safe side, >   if a compiler has doubts, >   it should diagnose. > >   There's some Clang document that talks about something similar. >   I don't know its validity, >   or if it was a draft before _Nonnull qualifiers. >   That document suggests that I shouldn't get a diagnostic from f(). Why did I get a diagnostic? (I tried clang 11, 13 & 14(experimental)) Is it talking about a different nonnull attribute/qualifier? Was it about a proposal prior to the current _Nonnull? Why is it not in use? Was it too difficult to implement? Do you think Clang could be improved to not warn on f()? Thanks, Alex