From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25687 invoked by alias); 13 Jun 2011 17:59:59 -0000 Received: (qmail 25678 invoked by uid 22791); 13 Jun 2011 17:59:58 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from g1t0028.austin.hp.com (HELO g1t0028.austin.hp.com) (15.216.28.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Jun 2011 17:59:41 +0000 Received: from g1t0039.austin.hp.com (g1t0039.austin.hp.com [16.236.32.45]) by g1t0028.austin.hp.com (Postfix) with ESMTP id D50561C18C; Mon, 13 Jun 2011 17:59:40 +0000 (UTC) Received: from lucas.cup.hp.com (lucas.cup.hp.com [15.244.97.116]) by g1t0039.austin.hp.com (Postfix) with ESMTP id 55EBE34461; Mon, 13 Jun 2011 17:59:40 +0000 (UTC) Received: (from sje@localhost) by lucas.cup.hp.com (8.11.1 (PHNE_35485)/8.11.1) id p5DHxcB08717; Mon, 13 Jun 2011 10:59:38 -0700 (PDT) Date: Mon, 13 Jun 2011 18:06:00 -0000 From: Steve Ellcey Message-Id: <201106131759.p5DHxcB08717@lucas.cup.hp.com> To: gcc-patches@gcc.gnu.org Subject: [patch, C++] Fix g++.dg/cpp0x/nullptr21.C on IA64 HP-UX Cc: jason@redhat.com, magfr@lysator.liu.se Reply-to: sje@cup.hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg00982.txt.bz2 The test g++.dg/cpp0x/nullptr21.C fails on IA64 HP-UX in 32 bit mode and in looking at the problem I tracked it down to some code in cxx_init_decl_processing that was added in r159131 to create nullptr_node: 2010-05-06 Magnus Fromreide Jason Merrill Add support for C++0x nullptr. The type for nullptr_node is nullptr_type_node and it is set up with a type, size, and alignment of ptr_mode. But the actual mode set with SET_TYPE_MODE is set to Pmode instead of ptr_mode. I don't know why, it may just be a typo. This causes problems on IA64 HP-UX in 32 bit mode because ptr_mode is 4 bytes (and 4 byte aligned) but Pmode is 8 bytes and 8 byte aligned. The code generated for nullptr21.C winds up doing an 8 byte load for nullptr on an address that is only 4 btye aligned and the code seg faults with a misaligned read. This patch changes Pmode to ptr_mode in the SET_TYPE_MODE call and that fixes the problem. It also caused no regressions on IA64 HP-UX, IA64 Linux, or x86 Linux. OK for checkin? Steve Ellcey sje@cup.hp.com 2011-06-13 Steve Ellcey * decl.c (cxx_init_decl_processing): Use ptr_mode instead of Pmode. Index: decl.c =================================================================== --- decl.c (revision 174979) +++ decl.c (working copy) @@ -3672,7 +3672,7 @@ 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); - SET_TYPE_MODE (nullptr_type_node, Pmode); + 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); }