From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id 5043F393C87E; Thu, 27 Aug 2020 18:07:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5043F393C87E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598551670; bh=NzoIRjbVfanxIoQrpYu9bE0XCxDgEvlrAMp4rrhztC8=; h=From:To:Subject:Date:From; b=SBGi/a8YBcLEggoNDyVLoaPBL44ZZ1L7c13Wq4+XwNGocPRFQ8bmUNlBEB9Pew0EH 33jGFEuerOl1LuC72PU4+lin/m6zOIyxGstkPGt6Zsqwpt6IQEkNSNKUwZ4soAWQnT zzUFPmeTDaNnPqTgSH6hux3c8nrpOH0f0MGAEK7Y= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/c++-modules] [nvptx] Fix array dimension in nvptx_assemble_decl_begin X-Act-Checkin: gcc X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/devel/c++-modules X-Git-Oldrev: fb8e83924615cf44332e60f910bf2b0128c21ae0 X-Git-Newrev: b9c7fe59f9f66ecc091e215c826ecd1a04d032dc Message-Id: <20200827180750.5043F393C87E@sourceware.org> Date: Thu, 27 Aug 2020 18:07:50 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2020 18:07:50 -0000 https://gcc.gnu.org/g:b9c7fe59f9f66ecc091e215c826ecd1a04d032dc commit b9c7fe59f9f66ecc091e215c826ecd1a04d032dc Author: Tom de Vries Date: Tue Aug 11 18:20:58 2020 +0200 [nvptx] Fix array dimension in nvptx_assemble_decl_begin When compiling test-case builtin-object-size-21.c, cc1 emits: ... .visible .global .align 1 .u32 xm3_3[-2305843009213693951] = ... for: ... struct Ax_m3 { char a[PTRDIFF_MAX - 3], ax[]; }; struct Ax_m3 xm3_3 = { { 0 }, { 1, 2, 3 } }; ... Fix this by: - changing the printing format for unsigned HOST_WIDE_INT init_frag.remaining to HOST_WIDE_INT_PRINT_UNSIGNED - changing the type of local variable elt_size in nvptx_assemble_decl_begin to unsigned HOST_WIDE_INT. such that we have: ... .visible .global .align 1 .u32 xm3_3[2305843009213693952] = ... where 2305843009213693952 == 0x2000000000000000, so the array is claiming 0x8000000000000000 bytes, which is one more than PTRDIFF_MAX. This is due to using .u32 instead of .u8, so strictly speaking we should downgrade to using .u8 in this case, but that corner-case problem doesn't look urgent enough to fix in this commit. Build on nvptx, tested with make check-gcc. gcc/ChangeLog: * config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Make elt_size an unsigned HOST_WIDE_INT. Print init_frag.remaining using HOST_WIDE_INT_PRINT_UNSIGNED. Diff: --- gcc/config/nvptx/nvptx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index cf53a921e5b..39d0275493a 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -2202,7 +2202,7 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section, /* Neither vector nor complex types can contain the other. */ type = TREE_TYPE (type); - unsigned elt_size = int_size_in_bytes (type); + unsigned HOST_WIDE_INT elt_size = int_size_in_bytes (type); /* Largest mode we're prepared to accept. For BLKmode types we don't know if it'll contain pointer constants, so have to choose @@ -2232,7 +2232,7 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section, if (size) /* We make everything an array, to simplify any initialization emission. */ - fprintf (file, "[" HOST_WIDE_INT_PRINT_DEC "]", init_frag.remaining); + fprintf (file, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", init_frag.remaining); else if (atype) fprintf (file, "[]"); }