From patchwork Mon Feb 24 18:09:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1243388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-520024-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=SWq5i1Vz; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OcMOzLp/; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48R98Z47kTz9sNg for ; Tue, 25 Feb 2020 05:10:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=uLGo2qXlQANdtpKS ONuGFwKDVdnbVv7RqoMWQmHQJbvdvfV0qSjS9YT6QIOFJN0zPWNM9sGITC0L7I0X NabIyoDwb5hg+gLlA8m/upzezaH+TDrvVhCmvLz9ZyjDYn66eomyfOUv6X9EQH3O m4CFSbjDQ3vjVAmHq4wH6iykM5s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=K2sDK7Y7a6V2BhAH9cEEvp gBkoM=; b=SWq5i1Vz5soOBv6oCD8+uyYAx9hYXYHCa4NZc47XQceiAjCmm77Ntu m2xwvzgrbMn5RsM7iwN7ILUMwVn/hYY36md2e3f0Ee6O5mAbsUDVunAHn1wbt/Hj dZEMl3T0k9cI3Xzg/p1Zn07m5WSMrUJCmwTV4LhhOcsWN8rMzhubc= Received: (qmail 95412 invoked by alias); 24 Feb 2020 18:10:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 95404 invoked by uid 89); 24 Feb 2020 18:10:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Feb 2020 18:10:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582567810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZQmUT7DUvi+zch5h9T/zc9XGOslJpofXmoH5EGfD+D0=; b=OcMOzLp/Goys9kkNZbHrPCemMPDop9t0wYHkR2VUrXOHT1Ays8M46/JcRN1eyRx4m38gHY /saimBlykxN9JYJU+6puNFMBBAL0uWtSGGhWiulZ7bnb5bBFBk1NsTECE8OyXVmz08Y2mo 003C5xD3qGcuGFP8CBGNrRl2PX1zbdg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-icXKTeaZPO6LRFG8604Xpg-1; Mon, 24 Feb 2020 13:10:08 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC71A100EB0E for ; Mon, 24 Feb 2020 18:10:07 +0000 (UTC) Received: from pdp-11.redhat.com (ovpn-127-158.rdu2.redhat.com [10.10.127.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BB2860F80; Mon, 24 Feb 2020 18:10:04 +0000 (UTC) From: Marek Polacek To: Jason Merrill , GCC Patches Subject: [PATCH] c++: Add test for DR 1423, Convertibility of nullptr to bool. Date: Mon, 24 Feb 2020 13:09:56 -0500 Message-Id: <20200224180956.402391-1-polacek@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com DR 1423, which supersedes DR 654, says that you can't copy-init a bool from a std::nullptr_t: bool b = nullptr; // error Conversely, it works with direct-initialization which is more permissive than copy-initialization. No code changes necessary since we handle it right. Tested on x86_64-linux, ok for trunk? 2020-02-24 Marek Polacek DR 1423, Convertibility of nullptr to bool. * g++.dg/DRs/dr1423.C: New test. --- gcc/testsuite/g++.dg/DRs/dr1423.C | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 gcc/testsuite/g++.dg/DRs/dr1423.C base-commit: a4dbb9b25a60143c699de55cd6226cebeb3b3c3e diff --git a/gcc/testsuite/g++.dg/DRs/dr1423.C b/gcc/testsuite/g++.dg/DRs/dr1423.C new file mode 100644 index 00000000000..d82baae9985 --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr1423.C @@ -0,0 +1,7 @@ +// DR 1423 - Convertibility of nullptr to bool. +// { dg-do compile { target c++11 } } + +bool b = nullptr; // { dg-error "converting to .bool. from .std::nullptr_t. requires direct-initialization" } +bool b2(nullptr); +bool b3{nullptr}; +bool b4 = { nullptr }; // { dg-error "converting to .bool. from .std::nullptr_t. requires direct-initialization" }