Re: A: a new bug to old plain C

LIU Hao via Gcc-help <[email protected]>
Newsgroups gmane.comp.gcc.help
Message-ID <[email protected]>
在 2025-11-26 17:37, Александр Поваляев 写道:
> Hi there!
> 
> The code below works fine on all the GCC compilers. It doesn't provide either errors or warnings.
> 
> "
> struct zzz {
> unsigned x, y;
> };
> 
> 
> void square(struct zzz * arr_of_ptr, unsigned count) {
> 
> struct zzz * const ptr1 = arr_of_ptr; // OK!
> struct zzz const * ptr2 = arr_of_ptr; // OK!
> struct zzz const * const ptr3 = arr_of_ptr; // OK!
> 
> }
> "

These are not the same as your original code. These are pointers to 'qualified or unqualified versions of 
compatible type(s)', where the 'compatible type' is `struct zzz *`.

In your original code there's `struct zzz ** arr_of_ptr` which points to `struct zzz *`, and there's 
`struct zzz const * const * const end_of_arr` which points to const-qualified `struct zzz const *`, so 
those pointers point to incompatible different types, and are not convertible.



-- 
Best regards,
LIU Hao
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEYmSQWY4DEzq4FUs4hfveZl3ogBsFAmkmzJIFAwAAAAAACgkQhfveZl3ogBul
DQ/6A7awheNxetgZhj7GcxChvqiqkRfhbKfvVjL+kLD/qNggteCUalg5EiCBjTtRF3fUrKrRwHhI
RZtSVYeaX39Zo3ptVVBNQrkOgksvzUsaOHa3Rphm2JrJhiVQhUW3LSqH51Pdm42Ec4z4EJpENYnY
M7Uh5UKfh6GLfWwbYCO9F6KxgZZ38unAd1cBTPDxqansLKmXmILzSyKZTRV95Hk+PPbQToTRcCCO
J2WGf2qjxxzecdUv+xZ0h8CZ2xlcS0d57yL6vNclTs2F74y1o+rx/2yy8AxnfBRdV2F5ioqW16It
yjdhvkR7SdDeSW1pmhIPe+dFrugkS997/XvEuE3YU98Oxop2WOoOzM5nOKZu6N+QTGStuGXlJlED
n6+ik6vKHVBdD+b6Cja/zuEoExYSuuXO3AkzbCGkkwvG6e+/E9y52ODGSkRMYXHQhJ+I1R/nGX3X
t8N9enuoZ8kBgwPqhDSkQv3fu+COQOQMt7DiwJfT+pWJqYKdz8PQbiHcBudIqLcTm+16+oRwWO6S
phXRXPIWpQer71IGy8HEvg+ZkgnqsJ8s510UYABYycy/jfqhlFue4WBg48upYsQwdtDkVKI8rs3z
xlI76qUG5OhVLa4JJmxLf9kVyr96iA++N4AbaTvDl81P3QjTUTDxxsabMAIQmCy2tds6WgKjPnAs
TNo=
=x79g
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.