bug-coreutils
[Top][All Lists]
Advanced

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

Re: verify.h: don't accept non-constant expressions


From: Paul Eggert
Subject: Re: verify.h: don't accept non-constant expressions
Date: Tue, 06 Sep 2005 01:24:12 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> +# if __GNUC__ <= 2
> +#  defined __builtin_constant_p(R) 1
> +# endif

Hmm, "defined"?

While looking into this, I found an alternate approach that should
work with all ANSI C compilers, rather than relying on a special
feature of GCC.  I installed this patch instead:

2005-09-06  Paul Eggert  <address@hidden>

        * verify.h (verify_type__): Solve the problem by using a bit-field
        rather than an array.

Index: verify.h
===================================================================
RCS file: /fetish/cu/lib/verify.h,v
retrieving revision 1.5
retrieving revision 1.7
diff -p -u -r1.5 -r1.7
--- verify.h    11 Jul 2005 23:28:09 -0000      1.5
+++ verify.h    6 Sep 2005 08:20:56 -0000       1.7
@@ -30,7 +30,7 @@
    are private to this header file.  */
 
 # define verify_type__(R) \
-    struct { int verify_error_if_negative_size__[(R) ? 1 : -1]; }
+    struct { int verify_error_if_negative_size__ : (R) ? 1 : -1; }
 
 /* Verify requirement R at compile-time, as a declaration.
    R should be an integer constant expression.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]