Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Fix compile error in configure script

Edgar Bonet
May 18, 2024 08:46AM
Hello!

Yesterday, I wrote:
> My understanding is that the compiler considers 'int' and 'long' to be
> incompatible types [... On ILP32,] 'size_t' being an 'unsigned int',
> it is incompatible with 'long'.
>
> On LP64 (your typical 64-bit Linux/Mac), 'size_t' is a 'unsigned
> long', which is compatible with 'long' but for the signedness warning.

I just did a small experiment to confirm all this. It shows that this
“incompatible pointer type” error is specific to GCC 14 compiling for
32-bit targets. I natively compiled the following C file:

#include <stddef.h>

void callee(size_t *);

void caller(void)
{
long n;
callee(&n);
}

on three different systems:

1. gcc 11.4 / Ubuntu 22.04 / x86_64 (desktop PC, 64 bits)
2. gcc 12.2 / Debian 12 / i686 (Acer Aspire One A110L, 32 bits)
3. gcc 10.2 / Raspbian 11 / armv6l (Raspberry Pi model B, 32 bits)

On the 64-bit PC, the compiler issues no warnings unless I explicitly
request them (e.g., with -Wall). If I do so, I get the signedness
warning:

warning: pointer targets in passing argument 1 of ‘callee’
differ in signedness [-Wpointer-sign]
note: expected ‘size_t *’ {aka ‘long unsigned int *’}
but argument is of type ‘long int *’

On both 32-bit systems, I get the following warning even with no -W*
option:

warning: passing argument 1 of ‘callee’
from incompatible pointer type [-Wincompatible-pointer-types]
note: expected ‘size_t *’ {aka ‘unsigned int *’}
but argument is of type ‘long int *’

This shows that:

* ‘size_t’ is ‘unsigned int’ on ILP32 and ‘long unsigned int’ on LP64

* ‘int’ and ’long int’ are considered incompatible even on ILP32,
where they have the same size.

What changes with GCC 14 is that the “incompatible pointer type” warning
has been changed to an error. The GCC 14 porting guide states:[1]

Type checking on pointer types (-Werror=incompatible-pointer-types)

GCC no longer allows implicitly casting all pointer types to all
other pointer types.

This is confirmed by the documentation of the option
-Wno-incompatible-pointer-types, which contains this sentence:[2]

By default, in C99 and later dialects of C, GCC treats this issue as
an error.

The sentence is absent from the GCC 13 documentation of the same
option.[3]

Regards,

Edgar.

[1] https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types
[2] https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Warning-Options.html#index-Wno-incompatible-pointer-types
[3] https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Warning-Options.html#index-Wno-incompatible-pointer-types
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Fix compile error in configure script

Edgar Bonet 231 May 16, 2024 05:26AM

Re: [PATCH] Fix compile error in configure script

Sergey Kandaurov 49 May 17, 2024 01:44PM

Re: [PATCH] Fix compile error in configure script

Edgar Bonet 54 May 17, 2024 03:28PM

Re: [PATCH] Fix compile error in configure script

Edgar Bonet 56 May 18, 2024 08:46AM

Re: [PATCH] Fix compile error in configure script

Sergey Kandaurov 50 May 20, 2024 04:22PM

Re: [PATCH] Fix compile error in configure script

Edgar Bonet 76 May 20, 2024 04:52PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready