Thread overview
static assertions support and GCC 4.1.2
Jun 27, 2008
ehrhart.dev.nospam
Jul 03, 2008
Matthew Wilson
Sep 14, 2008
Matthew Wilson
June 27, 2008
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)
# if (  defined(STLSOFT_COMPILER_IS_GCC) && \
        (   __GNUC__ < 3 || \
            (   __GNUC__ == 3 && \
                __GNUC_MINOR__ < 4))) || \
     defined(STLSOFT_COMPILER_IS_INTEL)
#   define STLSOFT_STATIC_ASSERT(ex)        do { typedef int ai[(ex) ?
1 : -1]; } while(0)
#  else /* ? compiler */
#   define STLSOFT_STATIC_ASSERT(ex)        do { typedef int ai[(ex) ? 1 :
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

July 03, 2008
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)
> # if (  defined(STLSOFT_COMPILER_IS_GCC) && \
>         (   __GNUC__ < 3 || \
>             (   __GNUC__ == 3 && \
>                 __GNUC_MINOR__ < 4))) || \
>      defined(STLSOFT_COMPILER_IS_INTEL)
> #   define STLSOFT_STATIC_ASSERT(ex)        do { typedef int ai[(ex) ?
> 1 : -1]; } while(0)
> #  else /* ? compiler */
> #   define STLSOFT_STATIC_ASSERT(ex)        do { typedef int ai[(ex) ? 1 :
> 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
> 

September 14, 2008
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)
> # if (  defined(STLSOFT_COMPILER_IS_GCC) && \
>         (   __GNUC__ < 3 || \
>             (   __GNUC__ == 3 && \
>                 __GNUC_MINOR__ < 4))) || \
>      defined(STLSOFT_COMPILER_IS_INTEL)
> #   define STLSOFT_STATIC_ASSERT(ex)        do { typedef int ai[(ex) ?
> 1 : -1]; } while(0)
> #  else /* ? compiler */
> #   define STLSOFT_STATIC_ASSERT(ex)        do { typedef int ai[(ex) ? 1 :
> 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
>