bug-textutils
[Top][All Lists]
Advanced

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

Re: textutils -> od 2.0.14 bug - solved


From: Jim Meyering
Subject: Re: textutils -> od 2.0.14 bug - solved
Date: Wed, 22 May 2002 09:21:45 +0200
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2.50 (i686-pc-linux-gnu)

"Eric Backus" <address@hidden> wrote:
...
> I have verified that MS Visual C++ 6.0 produces an error when given the
> above code.  I also verified that gcc 2.95.2 accepts it without any
> warnings, but does produce a warning for it if given the "-pedantic" flag.

Thanks for pointing that out.
Here's an additional patch that fixes that.
Now, the array dimension is +1 or -1.

Index: od.c
===================================================================
RCS file: /fetish/textutils/src/od.c,v
retrieving revision 1.126
diff -u -p -u -p -r1.126 od.c
--- od.c        14 May 2002 21:31:42 -0000      1.126
+++ od.c        22 May 2002 07:14:54 -0000
@@ -153,10 +153,10 @@ static const int width_bytes[] =
 
 /* Ensure that for each member of `enum size_spec' there is an
    initializer in the width_bytes array.  */
-struct assert_width_bytes_matches_size_spec_decl
+struct dummy
 {
-  int t1[sizeof width_bytes / sizeof width_bytes[0] - N_SIZE_SPECS];
-  int t2[N_SIZE_SPECS - sizeof width_bytes / sizeof width_bytes[0]];
+  int assert_width_bytes_matches_size_spec_decl
+    [sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS ? 1 : -1];
 };
 
 /* Names for some non-printing characters.  */

>> > As an alternative, you could have an N_WIDTH_BYTES entry at the end of
> the
>> > width_bytes array, and then have something like:
>> >
>> > #if N_SIZE_SPECS != N_WIDTH_BYTES
>> > #error Array size mismatch
>> > #endif

That is indeed more readable.  But I don't see how to
get N_WIDTH_BYTES automatically without using sizeof.
If you can make that work, please send a complete patch.

> To force the two arrays to have the same size, I find the above #if
> statement much more straightforward than the
> structure-with-zero-length-arrays anyway.



reply via email to

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