[Bug 25945] New: C_ASSERT doesn't fail if given non-constant expression

wine-bugs at winehq.org wine-bugs at winehq.org
Mon Jan 31 19:06:21 CST 2011


http://bugs.winehq.org/show_bug.cgi?id=25945

           Summary: C_ASSERT doesn't fail if given non-constant expression
           Product: Wine
           Version: 1.1.22
          Platform: x86
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: -unknown
        AssignedTo: wine-bugs at winehq.org
        ReportedBy: alexander.scott.johns+winebug at googlemail.com


In commit wine-1.1.21-63-g5d31eb9 AJ changed the definition of C_ASSERT (in
include/winnt.h) to make it compatible with newer versions of GCC.

Roughly, the change was:

-#define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1] __attribute__((unused))
+#define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])

Unfortunately, in GCC 4.4.3, the new definition of C_ASSERT doesn't fail when
given a non-constant expression. E.g.:

  C_ASSERT(rand() == -1);      /* ignored */

I think this is because GCC (as per C99) is treating the parameter of
__C_ASSERT__ as a VLA (variable length array), and so its type is equivalent to
int[*].

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list