Skip to content

Commit b8ac415

Browse files
committed
🐛 [sizeof] Wknd to support GCC >= 10
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.
1 parent 2d598be commit b8ac415

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

include/boost/sml.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
#define __BOOST_SML_UNUSED __attribute__((unused))
3737
#define __BOOST_SML_VT_INIT \
3838
{}
39+
#if (__GNUC__ < 10)
3940
#define __BOOST_SML_ZERO_SIZE_ARRAY(...) __VA_ARGS__ _[0]
41+
#else
42+
#define __BOOST_SML_ZERO_SIZE_ARRAY(...)
43+
#endif
4044
#define __BOOST_SML_ZERO_SIZE_ARRAY_CREATE(...) __VA_ARGS__ ? __VA_ARGS__ : 1
4145
#define __BOOST_SML_TEMPLATE_KEYWORD template
4246
#pragma GCC diagnostic push

test/ft/sizeof.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ test sm_sizeof_no_capture = [] {
206206
// clang-format on
207207
}
208208
};
209+
#if defined(__clang__) or (__GNUC__ < 10)
209210
static_expect(1 /*current_state=1*/ == sizeof(sml::sm<no_capture_transition>));
211+
#endif
210212
};
211213

212214
test sm_sizeof_more_than_256_transitions = [] {
@@ -476,6 +478,8 @@ test sm_sizeof_more_than_256_transitions = [] {
476478
// clang-format on
477479
}
478480
};
481+
#if defined(__clang__) or (__GNUC__ < 10)
479482
static_expect(2 /*current_state=2*/ == sizeof(sml::sm<c>));
483+
#endif
480484
};
481485
#endif

tools/pph.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ pph() {
3737
echo "#endif"
3838
echo "#define __BOOST_SML_UNUSED __attribute__((unused))"
3939
echo "#define __BOOST_SML_VT_INIT {}"
40+
echo "#if (__GNUC__ < 10)"
4041
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY(...) __VA_ARGS__ _[0]"
42+
echo "#else"
43+
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY(...)"
44+
echo "#endif"
4145
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY_CREATE(...) __VA_ARGS__ ? __VA_ARGS__ : 1"
4246
echo "#define __BOOST_SML_TEMPLATE_KEYWORD template"
4347
echo "#pragma GCC diagnostic push"

0 commit comments

Comments
 (0)