bug-gnulib
[Top][All Lists]
Advanced

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

Re: verify fails on ia64-hpux11.23 in libunistring-0.9.3


From: Gary V. Vaughan
Subject: Re: verify fails on ia64-hpux11.23 in libunistring-0.9.3
Date: Mon, 2 May 2011 00:15:55 +0700
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Paul,

Thanks for the pointers.

On Sun, May 01, 2011 at 09:15:01AM -0700, Paul Eggert wrote:
> So, the problem is that TYPE_MAXIMUM (uint_fast8_t)
> expands to 2**32 - 1, whereas it should expand to
> 2**64 - 1.

On the contrary, it looks TYPE_MAXIMUM (uint_fast8_t) is working in
both ABIs (2**32-1 for the 32 bit ABI, and 2**61-1 for the 64 bit ABI),
but UINT_FAST8_MAX is always 2**32-1 irrespective of the ABI, and is
thus a mismatch for verify() when compared to the 64 bit result of
TYPE_MAXIMUM.

> Can you use cc -E to find what expression
> TYPE_MAXIMUM (uint_fast8_t) expands to, and
> investigate why that expansion evaluates to the
> wrong value?

$ pwd
/opt/build/libunistring-0.9.3/tests
$ cat ,t.c
#include <stdint.h>                                                             
#include "intprops.h"                                                           
int main (int argc, char **argv) {
  printf("%lx\n", (unsigned long) TYPE_MAXIMUM (uint_fast8_t));
  printf("%lx\n", (unsigned long) UINT_FAST8_MAX);
  return 0;
}
$ cc -E -I. -I../lib +DD64 ,t.c |tail -n 5
int main (int argc, char **argv) {
  printf("%lx\n", (unsigned long) ((gl_uint_fast8_t) (! (! ((gl_uint_fast8_t) 0 
< (gl_uint_fast8_t) -1)) ? (gl_uint_fast8_t) -1 : ~ (~ (gl_uint_fast8_t) 0 << 
(sizeof (gl_uint_fast8_t) * 8 - 1)))));
  printf("%lx\n", (unsigned long) 4294967295U);
  return 0;
}
$ cc -E -I. -I../lib ,t.c |tail -n 5 
int main (int argc, char **argv) {
  printf("%lx\n", (unsigned long) ((gl_uint_fast8_t) (! (! ((gl_uint_fast8_t) 0 
< (gl_uint_fast8_t) -1)) ? (gl_uint_fast8_t) -1 : ~ (~ (gl_uint_fast8_t) 0 << 
(sizeof (gl_uint_fast8_t) * 8 - 1)))));
  printf("%lx\n", (unsigned long) 4294967295U);
  return 0;
}

> My impression is that TYPE_MAXIMUM (uint_fast8_t)
> should expand to (unsigned long) -1, which should be
> 2**64 - 1 on ia64-hpux11.23, but evidently that is not happening
> correctly.  Perhaps it's a compiler bug?

With respect to my first comment above, it seems that gnulib/stdint.h
always defines UINT_FAST8_MAX to ULONG_MAX, and yet on ia64*-hpux11.23
UINT_FAST8_MAX always seems to be 2**32-1.

Looking at /usr/include/limits.h, the definition of ULONG_MAX as a 32
or 64 bit value appears to be predicated on the presence of the pre-
processor symbol __LP64__, as set automatically by the +DD64 ABI switch
on the compiler command line:

#  ifdef __LP64__
#    if defined(__STDC__) || defined(__cplusplus)
#      define ULONG_MAX 18446744073709551615UL /* max value of a unsigned long 
int */
#    else /* not __STDC__ || __cplusplus */
#      define ULONG_MAX 01777777777777777777777  /* max value of a unsigned 
long int */
#    endif /* else not __STDC__ || __cplusplus */
#  else  /* __LP64__ */
#    if defined(__STDC__) || defined(__cplusplus)
#      define ULONG_MAX 4294967295UL /* max value of a unsigned long int */
#    else /* not __STDC__ || __cplusplus */
#      define ULONG_MAX 037777777777  /* max value of a unsigned long int */
#    endif /* else not __STDC__ || __cplusplus */
#  endif /* __LP64__ */

ULONG_MAX *really does* get the right value according to the system
header code above.  But somehow UINT_FAST8_MAX does not pick it up.

$ pwd
/opt/build/libunistring-0.9.3/tests
$ cat ,t.c
#include <stdint.h>
#include "intprops.h"
int main (int argc, char **argv) {
  printf("%lu\n", (unsigned long) ULONG_MAX);
  printf("%lu\n", (unsigned long) UINT_FAST8_MAX);
  return 0;
}
$ cc -I. -I../lib -o ,t ,t.c && ./,t
4294967295
4294967295
$ cc -I. -I../lib +DD64 -o ,t ,t.c && ./,t 
18446744073709551615
4294967295

I have no idea why or how that is happening though :(  Maybe as simple
as header ordering?

It's notable that neither ia64*-hpux11.31 nor hppa*-hpux11.23 have this
problem - only ia64*-hpux11.23!

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)

Attachment: pgpSOOw0n23bC.pgp
Description: PGP signature


reply via email to

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