From b7a588167cfd73681487917f762e4789b3c9fd68 Mon Sep 17 00:00:00 2001
From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com>
Date: Mon, 27 Sep 2021 09:04:15 +0200
Subject: [PATCH] Avoid bad_node_size exception when cross building (#2231)

* Refs 12581. Avoid bad_node_size exception

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 12583. Uncrustify.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
(cherry picked from commit 1484609fb2ea5c0d67d490f0c4444bd736a83648)

Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
---
 .../impl/node-sizes/custom/tree_node_size_impl.hpp    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/cpp/utils/collections/impl/node-sizes/custom/tree_node_size_impl.hpp b/src/cpp/utils/collections/impl/node-sizes/custom/tree_node_size_impl.hpp
index c7231955b47..30004cc11cf 100644
--- a/src/cpp/utils/collections/impl/node-sizes/custom/tree_node_size_impl.hpp
+++ b/src/cpp/utils/collections/impl/node-sizes/custom/tree_node_size_impl.hpp
@@ -23,7 +23,14 @@
 template<typename T>
 struct my_tree_node_type
 {
-    // There is an enum rb_tree_colo {false, true} here on libstdc++, it has been included below on other_info
+    // There is an enum tree_color {false, true} here on libstdc++, we should include it here to
+    // ensure there are no alignment issues
+    enum color_t
+    {
+        RED = false,
+        BLACK = true
+    }
+    color;
 
     // Three pointers on MSVC and libstdc++, two on libc++
     my_tree_node_type* parent;
@@ -44,4 +51,4 @@ struct tree_node_size : std::integral_constant<size_t, sizeof(my_tree_node_type<
 {
 };
 
-#endif  /* SRC_CPP_UTILS_COLLECTIONS_IMPL_CUSTOM_TREE_NODE_SIZE_IMPL_HPP_ */
\ No newline at end of file
+#endif  /* SRC_CPP_UTILS_COLLECTIONS_IMPL_CUSTOM_TREE_NODE_SIZE_IMPL_HPP_ */