Skip to content

Commit

Permalink
🐛 [sizeof] Wknd to support GCC >= 10
Browse files Browse the repository at this point in the history
Problem:
- GCC >=10 doesn't compile with `array[0]` trick to make SML as small as possible.

Solution:
- Remove the zero sized array trick for GCC >= 10.
- Disable sizeof verifcation for GCC >= 10.

Note:
- Another solution has to be considered/implemented.
  • Loading branch information
krzysztof-jusiak committed Jun 14, 2020
1 parent 2d598be commit b8ac415
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/boost/sml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
#define __BOOST_SML_UNUSED __attribute__((unused))
#define __BOOST_SML_VT_INIT \
{}
#if (__GNUC__ < 10)
#define __BOOST_SML_ZERO_SIZE_ARRAY(...) __VA_ARGS__ _[0]
#else
#define __BOOST_SML_ZERO_SIZE_ARRAY(...)
#endif
#define __BOOST_SML_ZERO_SIZE_ARRAY_CREATE(...) __VA_ARGS__ ? __VA_ARGS__ : 1
#define __BOOST_SML_TEMPLATE_KEYWORD template
#pragma GCC diagnostic push
Expand Down
4 changes: 4 additions & 0 deletions test/ft/sizeof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ test sm_sizeof_no_capture = [] {
// clang-format on
}
};
#if defined(__clang__) or (__GNUC__ < 10)
static_expect(1 /*current_state=1*/ == sizeof(sml::sm<no_capture_transition>));
#endif
};

test sm_sizeof_more_than_256_transitions = [] {
Expand Down Expand Up @@ -476,6 +478,8 @@ test sm_sizeof_more_than_256_transitions = [] {
// clang-format on
}
};
#if defined(__clang__) or (__GNUC__ < 10)
static_expect(2 /*current_state=2*/ == sizeof(sml::sm<c>));
#endif
};
#endif
4 changes: 4 additions & 0 deletions tools/pph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ pph() {
echo "#endif"
echo "#define __BOOST_SML_UNUSED __attribute__((unused))"
echo "#define __BOOST_SML_VT_INIT {}"
echo "#if (__GNUC__ < 10)"
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY(...) __VA_ARGS__ _[0]"
echo "#else"
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY(...)"
echo "#endif"
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY_CREATE(...) __VA_ARGS__ ? __VA_ARGS__ : 1"
echo "#define __BOOST_SML_TEMPLATE_KEYWORD template"
echo "#pragma GCC diagnostic push"
Expand Down

0 comments on commit b8ac415

Please sign in to comment.