Invalid static assert
Doug Cook <[email protected]>
| Newsgroups | gmane.comp.audio.mp3.lame |
|---|---|
| Message-ID | <CAMjYhzs4SsarEt9FQ9GxyF1C0kNTKJhOXK++kXgCq+4EvFfHeg@mail.gmail.com> |
The existing static assert used in machine.h and psymodel.c is problematic.
#define STATIC_ASSERT_EQUAL_DIMENSION(A,B) \
{extern char static_assert_##A[dimension_of(A) == dimension_of(B) ? 1
: -1];(void) static_assert_##A;}
It creates a symbol and references it, meaning the symbol may not be
optimized away. In addition, while this is probably a compiler bug, it
does fail to compile when using the VC2012 beta with LTCG enabled.
My preferred definition for this static assertion is as follows:
#define STATIC_ASSERT_EQUAL_DIMENSION(A,B) \
enum {static_assert_##A = 1/((dimension_of(A) == dimension_of(B)) ? 1 : 0)}
This works, doesn't define anything, and fixes my build failure.
Please consider fixing this.
Thanks!
Doug
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure