[openssl-project] OS/X builds failing

Viktor Dukhovni openssl-users at dukhovni.org
Fri Feb 9 16:52:48 UTC 2018

> On Feb 9, 2018, at 11:36 AM, Viktor Dukhovni <openssl-users at dukhovni.org> wrote:
> $ cat size.c
> #include <stdio.h>
> #include <stdint.h>
> int main(int argc, char **argv)
> {
>        printf("char = %zu\n", sizeof(unsigned char));
>        printf("short = %zu\n", sizeof(unsigned short));
>        printf("int = %zu\n", sizeof(unsigned int));
>        printf("long = %zu\n", sizeof(unsigned long int));
>        printf("long long = %zu\n", sizeof(unsigned long long int));
>        printf("int8_t = %zu\n", sizeof(uint8_t));
>        printf("int16_t = %zu\n", sizeof(uint16_t));
>        printf("int32_t = %zu\n", sizeof(uint32_t));
>        printf("int64_t = %zu\n", sizeof(uint64_t));
>        printf("intmax_t = %zu\n", sizeof(uintmax_t));
>        return 0;
> }
> shows that long, long long, int64_t and intmax_t are presently all the same.

And throwing an extra line with a cast, yields the expected warning:

$ cc -o size size.c
size.c:18:36: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'unsigned long long'
        printf("intmax_t = %ju\n", (unsigned long long)sizeof(uintmax_t));
                           ~~~     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Interestingly casting to "unsigned long" instead of "unsigned long long" does not result
in a warning.  The warning is about the underlying C type, and expands typedefs.  So it
is a bit annoying that typedefs that might change are not a problem, but "long long"
vs. "long" is even though they are actually the same underlying data type.

Still, we're wrong to use int64_t values with "%j" formats.  All format
arguments to "%j" need to be "intmax_t".


More information about the openssl-project mailing list