bug-gnulib
[Top][All Lists]
Advanced

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

Re: tar 1.19 - vms time_t is unsigned long. [partial patch[


From: Eric Blake
Subject: Re: tar 1.19 - vms time_t is unsigned long. [partial patch[
Date: Sat, 08 Mar 2008 14:59:07 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to John E. Malmberg on 3/8/2008 1:32 PM:
| I believe that this attached patch gets intprops.h TYPE_MAXIMUM to
| handle unsigned types.

TYPE_MAXIMUM already handles unsigned types.  It seems like you have a
buggy compiler, instead.

|
| A mask is needed because of an extension that most C compilers have that
| allow ((unsigned int) -1)  to be tested as being less than 0 through
| operand promotion.

Huh?  C99 6.3.1.8 states: "Otherwise, if the operand that has unsigned
integer type has rank greater or equal to the rank of the type of the
other operand, then the operand with signed integer type is converted to
the type of the operand with unsigned integer type."  There is no valid C
operand promotion that would ever let (unsigned int) compare less than
(int) 0, since the 0 is promoted to unsigned int (and not both operands
promoted to long or any other signed type of larger rank).

Furthermore, masking with LONG_MAX would break the macro when used with
'unsigned long long'.  But since your compiler appears to have a bug, what
if we do something like this to work around it, instead?

#define TYPE_MAXIMUM(t) \
~  ((t) (! TYPE_SIGNED (t) \
        ? (t) -1 \
- -     : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
+       : ~ (t) (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH0wwr84KuGfSFAYARAi+GAJwMP9HJA67EUnOzVvgZLXrsZWMQbQCdEcz9
uZbIG1rRh/ph9j6qEtwrwBE=
=sbSD
-----END PGP SIGNATURE-----




reply via email to

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