public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc/devel/c++-contracts] libstdc++: reorder contract_violation
Date: Wed,  2 Nov 2022 18:44:40 +0000 (GMT)	[thread overview]
Message-ID: <20221102184440.5B1F93857402@sourceware.org> (raw)

https://gcc.gnu.org/g:4f428e8b3f0a8a2ee282a952e1f70a8146478cdd

commit 4f428e8b3f0a8a2ee282a952e1f70a8146478cdd
Author: Jason Merrill <jason@redhat.com>
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 <contract>:
 	 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

                 reply	other threads:[~2022-11-02 18:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102184440.5B1F93857402@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).