From patchwork Fri Jun 19 19:54:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 486887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 0959114030B for ; Sat, 20 Jun 2015 05:54:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=cCdlDoOI; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=kOMZUJ1fBNP9IcNRbYZUYYJC6pTUN/a0oc3ctv1tbI985Y Vo7ae42L6i3LfJWJar0WLAsBpWA42NMPO2ddzNYjGGUnI34lDTSlAoIwrmANPwbc GWwW9qLkxynw1bv4C6+/WGzpKbHDxT1p3+ocsi1n0LafQcan93qFY/i29q94Q= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=TDHWbBLoHlNQXQEMohvAF13WSIQ=; b=cCdlDoOIQqz95nGkbTvw nUfQ/wX5IVCoKvPIuDdtBJJchqUqMXY0L0hnAcOoz75wX4yUP1buX3CTdh+R3q4X U0ZfFdqzvAFg/fM7/YZOShF/ovaJpIzBtpgK2HF4dMysyadjcHuC6bMhfPWkjLH0 pZaJKRxtC52kpeG4SHVbjTE= Received: (qmail 104382 invoked by alias); 19 Jun 2015 19:54:14 -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 104372 invoked by uid 89); 19 Jun 2015 19:54:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 19 Jun 2015 19:54:13 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 49AB283F68 for ; Fri, 19 Jun 2015 19:54:12 +0000 (UTC) Received: from [10.10.116.27] ([10.10.116.27]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5JJsBSl032598 for ; Fri, 19 Jun 2015 15:54:11 -0400 Message-ID: <5584735F.4090301@redhat.com> Date: Fri, 19 Jun 2015 15:54:07 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches List Subject: RFC (ABI): C++ PATCH for c++/65945 (wrong alignment of nullptr_t) When we set the size and precision of nullptr_t we forgot to set the alignment, so we end up with unaligned accesses that cause problems on some targets. The ABI has now been clarified to specify the alignment. My question is what to do about this for GCC 5.2. This is currently breaking things on some targets, but it's also a real ABI change. The effect should be moderated by the fact that nullptr_t has no value, but if we have a nullptr_t followed by another parameter of a different type, the location of that parameter could change. Any thoughts? commit eba1ee852a6814f0c9dfdc08826c32dfbca3a497 Author: Jason Merrill Date: Fri Jun 19 15:29:33 2015 -0400 PR c++/65945 * decl.c (cxx_init_decl_processing): Set TYPE_ALIGN of nullptr_t. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 515c2d3..a3fd5b6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3995,6 +3995,8 @@ cxx_init_decl_processing (void) TYPE_SIZE_UNIT (nullptr_type_node) = size_int (GET_MODE_SIZE (ptr_mode)); TYPE_UNSIGNED (nullptr_type_node) = 1; TYPE_PRECISION (nullptr_type_node) = GET_MODE_BITSIZE (ptr_mode); + if (abi_version_at_least (9)) + TYPE_ALIGN (nullptr_type_node) = GET_MODE_ALIGNMENT (ptr_mode); SET_TYPE_MODE (nullptr_type_node, ptr_mode); record_builtin_type (RID_MAX, "decltype(nullptr)", nullptr_type_node); nullptr_node = build_int_cst (nullptr_type_node, 0); diff --git a/gcc/testsuite/g++.dg/abi/nullptr-align.C b/gcc/testsuite/g++.dg/abi/nullptr-align.C new file mode 100644 index 0000000..7de365a --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/nullptr-align.C @@ -0,0 +1,5 @@ +// PR c++/65945 +// { dg-do compile { target c++11 } } +// { dg-options "-fabi-version=9" } + +static_assert(alignof (decltype (nullptr)) == alignof (void *), "");