www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - static assertions support and GCC 4.1.2

reply ehrhart.dev.nospam free.fr writes:
Hello,
I use the 1.9.44 version of the library and GCC 4.1.2.
I realize that static assertions are not fired when they are attended.

I check the STLSOFT_CF_STATIC_ASSERT_SUPPORT definition in stlsoft/stlsoft.h
-----------------------------------------------
#if defined(STLSOFT_CF_STATIC_ASSERT_SUPPORT)

        (   __GNUC__ < 3 || \
            (   __GNUC__ == 3 && \
                __GNUC_MINOR__ < 4))) || \
     defined(STLSOFT_COMPILER_IS_INTEL)

1 : -1]; } while(0)


0]; } while(0)
-------------------------------------------------
So with gcc 4.x, STATIC_ASSERT expands to ...ai[0]....
But accordingly to
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html#Zero-Length 
array of 0 length are allowed. That explains why the static assertion cannot
make the trick. We have to define -1 length.

I really have not the knowledge of gcc, have I missunderstand something ?
Thanks you
Manfred
Jun 27 2008
next sibling parent Matthew Wilson <no-one nowhere.none.com> writes:
Manfred

Thanks for the heads-up. I'll adjust accordingly in the next release

Cheers

Matt

ehrhart.dev.nospam free.fr Wrote:

 Hello,
 I use the 1.9.44 version of the library and GCC 4.1.2.
 I realize that static assertions are not fired when they are attended.
 
 I check the STLSOFT_CF_STATIC_ASSERT_SUPPORT definition in stlsoft/stlsoft.h
 -----------------------------------------------
 #if defined(STLSOFT_CF_STATIC_ASSERT_SUPPORT)

         (   __GNUC__ < 3 || \
             (   __GNUC__ == 3 && \
                 __GNUC_MINOR__ < 4))) || \
      defined(STLSOFT_COMPILER_IS_INTEL)

 1 : -1]; } while(0)


 0]; } while(0)
 -------------------------------------------------
 So with gcc 4.x, STATIC_ASSERT expands to ...ai[0]....
 But accordingly to
 http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html#Zero-Length 
 array of 0 length are allowed. That explains why the static assertion cannot
 make the trick. We have to define -1 length.
 
 I really have not the knowledge of gcc, have I missunderstand something ?
 Thanks you
 Manfred
 
Jul 03 2008
prev sibling parent "Matthew Wilson" <matthew hat.stlsoft.dot.org> writes:
Forgot about this one. Apologies.

Is now fixed and will be in next release.

<ehrhart.dev.nospam free.fr> wrote in message
news:g42lq6$22so$1 digitalmars.com...
 Hello,
 I use the 1.9.44 version of the library and GCC 4.1.2.
 I realize that static assertions are not fired when they are attended.

 I check the STLSOFT_CF_STATIC_ASSERT_SUPPORT definition in stlsoft/stlsoft.h
 -----------------------------------------------
 #if defined(STLSOFT_CF_STATIC_ASSERT_SUPPORT)

         (   __GNUC__ < 3 || \
             (   __GNUC__ == 3 && \
                 __GNUC_MINOR__ < 4))) || \
      defined(STLSOFT_COMPILER_IS_INTEL)

 1 : -1]; } while(0)


 0]; } while(0)
 -------------------------------------------------
 So with gcc 4.x, STATIC_ASSERT expands to ...ai[0]....
 But accordingly to
 http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html#Zero-Length
 array of 0 length are allowed. That explains why the static assertion cannot
 make the trick. We have to define -1 length.

 I really have not the knowledge of gcc, have I missunderstand something ?
 Thanks you
 Manfred
Sep 14 2008