From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 91AC338376B0 for ; Wed, 24 Aug 2022 18:24:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 91AC338376B0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661365478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3GGogVvqQGrDuL6PzT+rFV19yUE36zZbrb/fdrmbLh4=; b=iWSJXL0QRPPKBsc/KUf7gU5il5N6gi1mvnRU+HEZxhP4gvIO6AsM3gob+ZJf9a/bH00fdE 5CYMf3TIHYV/93IaR05h2f5Cl06SI7j3k+F7y5uuzBFSuWY9qRJFE244V9TCX9GhByniQx DfFQ9XyCrjCAbdhC/7wwXKAdD0wt4Y8= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-284--9Bx0Va_O_euIfxgqdHnfg-1; Wed, 24 Aug 2022 14:24:35 -0400 X-MC-Unique: -9Bx0Va_O_euIfxgqdHnfg-1 Received: by mail-qv1-f71.google.com with SMTP id m18-20020a0cf192000000b00496ac947c21so10068632qvl.4 for ; Wed, 24 Aug 2022 11:24:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=3GGogVvqQGrDuL6PzT+rFV19yUE36zZbrb/fdrmbLh4=; b=UKoj2R4niqXYYgZL+ZsR+iJVmDCsQx7E99fsbuB/x2AFiihxdLWuUv0t1WSR0ERMmM xSvkAzZTFIZ6HVhvYG4dow6yeYoz9uMK9atArtzUaKv98GhUrvOJZ+JF4xZkvKaU3I8l tibt5WenzzY/2ZFaMeh7LvtaJ3bMkh0pjYHmmQvEmi/CNRIAR9yB5b6h/ODxKg6M2dtg GxNrdVx5UEdKteI7fnP/WXdLMa/fJ77EtYhn2HczoWp29rMHJfOhHBoMgGuy5GN6NkQ/ sVH0CltIC3Nc30fV5xEKgCEZ1wrgxe7MMGJs4eaxCvgtHdugv6Ot1eoGbrpfNZn6MSPv ytmA== X-Gm-Message-State: ACgBeo3CRlV0Z3wfDmLJ5RvbliCOsn/TS0F9FERFzAR0f2upliwBfqXc FdwePREQXOiYFh0rQzIX2cJec3uhqXEUQxlQWnvwAY8giGVIlY5Gx2V4XC4ml/rZHSpezW/pzhr ZjMD3Uz++daLrKHJKiQ== X-Received: by 2002:a05:620a:25d0:b0:6bb:f597:1a3 with SMTP id y16-20020a05620a25d000b006bbf59701a3mr392985qko.43.1661365474574; Wed, 24 Aug 2022 11:24:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4FBHZWbU1Ogys/dChDV155AF8IRUZ78+CNgj4g+UCW8dKcjEHoh2xgz8jKzZE0mw591u5pgg== X-Received: by 2002:a05:620a:25d0:b0:6bb:f597:1a3 with SMTP id y16-20020a05620a25d000b006bbf59701a3mr392973qko.43.1661365474350; Wed, 24 Aug 2022 11:24:34 -0700 (PDT) Received: from redhat.com ([2601:184:4780:4310::e531]) by smtp.gmail.com with ESMTPSA id y206-20020a3764d7000000b006b9ab3364ffsm15139103qkb.11.2022.08.24.11.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 11:24:33 -0700 (PDT) Date: Wed, 24 Aug 2022 14:24:32 -0400 From: Marek Polacek To: Jason Merrill Cc: GCC Patches , Joseph Myers Subject: Re: [PATCH] c: Implement C23 nullptr (N3042) Message-ID: References: <20220813213504.568937-1-polacek@redhat.com> <38054995-48c3-8e98-623a-c2057ec70fb3@redhat.com> MIME-Version: 1.0 In-Reply-To: <38054995-48c3-8e98-623a-c2057ec70fb3@redhat.com> User-Agent: Mutt/2.2.6 (2022-06-05) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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: On Mon, Aug 15, 2022 at 04:03:13PM -0400, Jason Merrill wrote: > On 8/13/22 14:35, Marek Polacek wrote: > > This patch implements the C23 nullptr literal: > > , which is > > intended to replace the problematic definition of NULL which might be > > either of integer type or void*. > > > > Since C++ has had nullptr for over a decade now, it was relatively easy > > to just move the built-in node definitions from the C++ FE to the C/C++ > > common code. Also, our DWARF emitter already handles NULLPTR_TYPE by > > emitting DW_TAG_unspecified_type. However, I had to handle a lot of > > contexts such as ?:, comparison, conversion, etc. > > > > There are some minor differences, e.g. in C you can do > > > > bool b = nullptr; > > > > but in C++ you have to use direct-initialization: > > > > bool b{nullptr}; > > > > And I think that > > > > nullptr_t n = 0; > > > > is only valid in C++. > > > > Of course, C doesn't have to handle mangling, RTTI, substitution, > > overloading, ... > > > > This patch also defines nullptr_t in . I'm uncertain about > > the __STDC_VERSION__ version I should be checking. Also, I'm not > > defining __STDC_VERSION_STDDEF_H__ yet, because I don't know what value > > it should be defined to. Do we know yet? > > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > The C++ changes are OK, but you probably want a comment in > c_common_nodes_and_builtins that we aren't setting the alignment there for > C++ backward ABI bug compatibility. Or perhaps set it there and then break > it in the C++ front end when abi < 9. Thanks! I added a comment to that effect in the v2 patch I just posted. Marek