(DECIMAL_DIGIT_ACCUMULATE): Generate a hard error
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Jul 2005 22:20:17 +0000 (22:20 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Jul 2005 22:20:17 +0000 (22:20 +0000)
(not just a warning) if GCC is used and the types don't match.

ChangeLog
src/system.h

index 67e6d00..e730308 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
-2005-07-04  Paul Eggert  <eggert@cs.ucla.edu>
+2005-07-05  Paul Eggert  <eggert@cs.ucla.edu>
 
        * Version 5.3.1.
 
+       * src/system.h (DECIMAL_DIGIT_ACCUMULATE): Generate a hard error
+       (not just a warning) if GCC is used and the types don't match.
+
+2005-07-04  Paul Eggert  <eggert@cs.ucla.edu>
+
        * src/system.h (VERIFY_W_TYPEOF): Remove; no longer needed.
        (DECIMAL_DIGIT_ACCUMULATE): Change last arg from T's maximum value
        to T itself.  All callers changed.  Check that T is unsigned, and
index a22bfb0..e3a99ab 100644 (file)
@@ -811,13 +811,18 @@ ptr_align (void const *ptr, size_t alignment)
    then don't update Accum and return false to indicate it would
    overflow.  Otherwise, set Accum to that new value and return true.
    Verify at compile-time that Type is Accum's type, and that Type is
-   unsigned.  Accum must be an object, so that we can take its address.
-   Accum and Digit_val may be evaluated multiple times.  */
+   unsigned.  Accum must be an object, so that we can take its
+   address.  Accum and Digit_val may =be evaluated multiple times.
+
+   The "Added check" below is not strictly required, but it causes GCC
+   to return a nonzero exit status instead of merely a warning
+   diagnostic, and that is more useful.  */
 
 #define DECIMAL_DIGIT_ACCUMULATE(Accum, Digit_val, Type)               \
   (                                                                    \
    (void) (&(Accum) == (Type *) NULL),  /* The type matches.  */       \
    verify_expr (! TYPE_SIGNED (Type)),  /* The type is unsigned.  */   \
+   verify_expr (sizeof (Accum) == sizeof (Type)),  /* Added check.  */ \
    (((Type) -1 / 10 < (Accum)                                          \
      || (Type) ((Accum) * 10 + (Digit_val)) < (Accum))                 \
     ? false : (((Accum) = (Accum) * 10 + (Digit_val)), true))          \