From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 5B1F93857402; Wed, 2 Nov 2022 18:44:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B1F93857402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667414680; bh=ih1GhwHh4kedvR0zoRsy1fIxJX/FQDi+mOYdLts84J4=; h=From:To:Subject:Date:From; b=nZXRAkNDTvOiFl7slsfOTgp2MSUqYa7n8vF3lpE2LYVbgSb81w/Gxolsg02HKaekR WvilRCq+bITldAGij2ktzJo0Wnnh8O12Hx4vLamnbkdSXcavaPhJgrYq7GDfcQFH0u oLj/ChKsWzHbGkqB27xhg99POoUmtdGCUyNzmmFw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jason Merrill To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/c++-contracts] libstdc++: reorder contract_violation X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/devel/c++-contracts X-Git-Oldrev: bfcb6e7373095d776eeb505f6d1a7d04ada21a3c X-Git-Newrev: 4f428e8b3f0a8a2ee282a952e1f70a8146478cdd Message-Id: <20221102184440.5B1F93857402@sourceware.org> Date: Wed, 2 Nov 2022 18:44:40 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4f428e8b3f0a8a2ee282a952e1f70a8146478cdd commit 4f428e8b3f0a8a2ee282a952e1f70a8146478cdd Author: Jason Merrill Date: Tue Nov 1 10:38:02 2022 -0400 libstdc++: reorder contract_violation Moving the int after the pointers makes the object one word smaller. Diff: --- gcc/cp/contracts.cc | 8 ++++---- libstdc++-v3/src/experimental/contract.cc | 1 + libstdc++-v3/include/experimental/contract | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 6732b761183..3a0377089a0 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -1599,21 +1599,21 @@ get_pseudo_contract_violation_type () { /* Must match : class contract_violation { - uint_least32_t _M_line; const char* _M_file; const char* _M_function; const char* _M_comment; const char* _M_level; const char* _M_role; + uint_least32_t _M_line; signed char _M_continue; If this changes, also update the initializer in build_contract_violation. */ - const tree types[] = { uint_least32_type_node, - const_string_type_node, + const tree types[] = { const_string_type_node, const_string_type_node, const_string_type_node, const_string_type_node, const_string_type_node, + uint_least32_type_node, signed_char_type_node }; tree fields = NULL_TREE; for (tree type : types) @@ -1663,12 +1663,12 @@ build_contract_violation (tree contract, contract_continuation cmode) /* Must match the type layout in get_pseudo_contract_violation_type. */ tree ctor = build_constructor_va (init_list_type_node, 7, - NULL_TREE, build_int_cst (uint_least32_type_node, loc.line), NULL_TREE, build_string_literal (loc.file), NULL_TREE, build_string_literal (function), NULL_TREE, CONTRACT_COMMENT (contract), NULL_TREE, build_string_literal (level), NULL_TREE, build_string_literal (role), + NULL_TREE, build_int_cst (uint_least32_type_node, loc.line), NULL_TREE, build_int_cst (signed_char_type_node, cmode)); ctor = finish_compound_literal (get_pseudo_contract_violation_type (), diff --git a/libstdc++-v3/src/experimental/contract.cc b/libstdc++-v3/src/experimental/contract.cc index f1b6eb3a58a..b9b72cd7df0 100644 --- a/libstdc++-v3/src/experimental/contract.cc +++ b/libstdc++-v3/src/experimental/contract.cc @@ -38,3 +38,4 @@ handle_contract_violation (const std::experimental::contract_violation &violatio << " " << (int)violation.continuation_mode() << std::endl; } + diff --git a/libstdc++-v3/include/experimental/contract b/libstdc++-v3/include/experimental/contract index fb03f116847..16f3fd5fd5a 100644 --- a/libstdc++-v3/include/experimental/contract +++ b/libstdc++-v3/include/experimental/contract @@ -52,12 +52,12 @@ namespace experimental }; class contract_violation { - uint_least32_t _M_line; const char* _M_file; const char* _M_function; const char* _M_comment; const char* _M_level; const char* _M_role; + uint_least32_t _M_line; signed char _M_continue; public: // From N4820