Re: beast-0.7.4 issues with g++-4.5


On Tue, Apr 19, 2011 at 07:40:10PM +0200, Tim Janik wrote:
> On Tue, 19 Apr 2011, Stefan Westerfeld wrote:
> >On Sat, Apr 09, 2011 at 09:09:23PM +0200, Stefan Westerfeld wrote:
> >>CXX    birnetutils.lo
> >> error: array bound is not an integer constant before ']' token
> >> error: array bound is not an integer constant before ']' token
> >> error: array bound is not an integer constant before ']' token
> >
> >I investigated the issue a little further. First of all, I tried using BOOST_STATIC_ASSERT
> >instead of BIRNET_STATIC_ASSERT, just to see if our static assertion facility needs to
> >be fixed. However, BOOST_STATIC_ASSERT behaves the same way like BIRNET_STATIC_ASSERT:
> >it fails on those expressions involving DBL_MIN/DBL_MAX/DBL_EPSILON on g++-4.5, and
> >succeeds with g++-4.4. There are IMHO several ways to fix compilation with g++-4.5.
> >4) Move assertions to runtime checks at startup. For instance with global
> >constructors, we could keep the test in the same file, but the constructor
> >would do the assertions and prevent starting BEAST if the test does not work.
> >
> >5) We could disable these static assertions altogether (or conditionally for
> >g++ >= 4.5.0) , but I think thats not such a good option, as they were designed
> >to prevent problems down the road, so I'm not considering this at the moment.
> >
> >As there are multiple approaches on how to fix the issue, I'd like some
> >guidance here as on which approach to take. I can make a patch/merge request
> >for approach 2, 3 or 4, as soon as the decision on which route to take is made.
> I'd favor something similar to the effect of 4, but I really think the compiler
> needs fixing here. I.e. we should just hold the horses here and see how the GCC/Boost
> teams are sorting it out. Both have more resources and a wider user base than Beast,
> so being patient will just provide a solution automatically.
> Until then, only GCC-4.4 is supported by Beast/Rapicorn, which is fine.

I don't believe waiting will do much good, since in general the Boost and
Birnet static assertions work just fine. Its only if you use DBL_MIN/DBL_MAX or
DBL_EPSILON in a static assertions that g++-4.5 is rejecting the code. I
consider it unlikely that many projects will run into this specific problem.

Supporting only GCC-4.4 might be a problem for some packagers, and I'd rather
solve these problems as early as possible, to keep the packagers happy.

In any case, I've made an implementation for startup asserts, and put it into

branch: static-assert-fixes

I'm including the patch:

diff --git a/birnet/birnetcdefs.h b/birnet/birnetcdefs.h
index 0cb882c..7246a31 100644
--- a/birnet/birnetcdefs.h
+++ b/birnet/birnetcdefs.h
@@ -111,6 +111,15 @@ BIRNET_EXTERN_C_BEGIN();
 #define BIRNET_CPP_PASTE2(a,b)                  BIRNET_CPP_PASTE2i (a,b)
 #define BIRNET_STATIC_ASSERT_NAMED(expr,asname) typedef struct { char asname[(expr) ? 1 : -1]; } BIRNET_CPP_PASTE2 (Birnet_StaticAssertion_LINE, __LINE__)
 #define BIRNET_STATIC_ASSERT(expr)              BIRNET_STATIC_ASSERT_NAMED (expr, compile_time_assertion_failed)
+#define BIRNET_STARTUP_ASSERT_IMPL(expr,asname) \
+  namespace Birnet { \
+    namespace StartupAssert { \
+      struct asname { \
+        asname() { g_assert (expr); } \
+      } BIRNET_CPP_PASTE2(asname,_instance); \
+    } \
+  }
 /* --- attributes --- */
 #if     __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
diff --git a/birnet/ b/birnet/
index 6a45bda..4baae02 100644
--- a/birnet/
+++ b/birnet/
@@ -250,9 +250,9 @@ BIRNET_STATIC_ASSERT (UINT64_MAX   == +18446744073709551615LLU);

   Cu... Stefan
Stefan Westerfeld, Hamburg/Germany,

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]