From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id A837D3858C2F for ; Thu, 25 Aug 2022 17:28:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A837D3858C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,263,1654588800"; d="scan'208";a="81955995" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 25 Aug 2022 09:28:15 -0800 IronPort-SDR: 7XoO8J/ey929uhRP1UCQWZPmttyeIplwfSx2nur5/4/YlGI7Zc+eqZ0/O5dTLo8TRXCaSBhoC0 CEBRCFtEYU7G/YmG3lLxuXLGiKKVAledLN4cEuH+8o4yEDtM5WaHCdQX+B1OU6OJTqg1aYgtJ+ wvro/QyyzfnMdYzLLZyKigbWS6eTY//9M9iuJPjqfP+/osgpXALhTAaTukX6WVfNBnMoot0ATi cgiH+gxvJDRfSfyS0O6TVmna2w0mWCqtIsq4srX0vdmYcGOkxA7uf+q1IEPeyVAZX9U0BOgEsm Zq0= Date: Thu, 25 Aug 2022 17:28:09 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Marek Polacek CC: GCC Patches Subject: Re: [PATCH v2] c: Implement C23 nullptr (N3042) In-Reply-To: Message-ID: References: <20220813213504.568937-1-polacek@redhat.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3111.6 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: On Wed, 24 Aug 2022, Marek Polacek via Gcc-patches wrote: > Ah, okay. I had just copied what we do in C++ in null_ptr_cst_p and the > rest of the patch worked under that assumption. I've added some tests > for this too. Except I don't really understand the _Generic comment so > I only have tests for _Generic that were in the previous version. The point is that e.g. _Generic(0, int : nullptr) is treated the same as nullptr (so is a null pointer constant), just as (nullptr) is. > Thanks, tests added to c2x-nullptr-1.c:test1. I notice that 6.3.2.4 still > says "The type nullptr_t may be converted to bool or to a pointer type"; > isn't it missing the ", void" here too? In general none of the subclauses under 6.3.2 about individual kinds of types tend to discuss the possibility of conversion to void. > +/* Simple assignment. */ > +void > +test4 (void) > +{ > + /* -- the left operand has an atomic, qualified, or unqualified version of > + the nullptr_t type and the type of the right is nullptr_t; */ > + nullptr_t n1; > + n1 = nullptr; > + const nullptr_t n2 = nullptr; > + _Atomic nullptr_t n3 = nullptr; > + volatile nullptr_t n4 = nullptr; These qualified cases are all actually initialization, not assignment; I think both assignment and initialization (and argument passing and return) should be tested for the permitted cases for assignment. > +/* Test nullptr_t from ". > +/* If a second or third operand of type nullptr_t is used that is not a null > + pointer constant and the other operand is not a pointer or does not have > + itself nullptr_t, a constraint is violated even if that other operand is > + a null pointer constant such as 0. */ The "that is not a null pointer constant" in that footnote is a bit odd, since it's also a constraint violation (and should be tested as such) to have a conditional expression between e.g. nullptr and 0. -- Joseph S. Myers joseph@codesourcery.com