Bruno Haible via Gnulib discussion list <bug-gnulib@gnu.org> writes:

> I promised:
>>   - see how this new warning behaves on the Gnulib source code
>
> The two good news are:
>   - The warning is really helpful. With it, I could find all relevant uses of
>     '0' quickly. Patch attached and committed.
>   - There were no false positives.
>
> However, there are warnings that are not in the responsibility of a package
> maintainer:
>
>   * Anywhere a pthread_mutex_t is initialized, the warning appears. This is
>     because on glibc, the macro __PTHREAD_MUTEX_INITIALIZER(__kind)
>     expands to
>       0, 0, 0, 0, __kind, 0, 0, { 0, 0 }
>     It should better expand to
>       0, 0, 0, 0, __kind, 0, 0, { NULL, NULL }
>
>   * gperf generated code has these warnings:
>     unicase/special-casing-table.gperf:171:10: warning: zero as null pointer 
> constant [-Wzero-as-null-pointer-constant]
>     unictype/categ_byname.gperf:115:10: warning: zero as null pointer 
> constant [-Wzero-as-null-pointer-constant]
>     unictype/incb_byname.gperf:60:10: warning: zero as null pointer constant 
> [-Wzero-as-null-pointer-constant]
>     unictype/joininggroup_byname.gperf:131:10: warning: zero as null pointer 
> constant [-Wzero-as-null-pointer-constant]
>     unictype/pr_byname.gperf:114:10: warning: zero as null pointer constant 
> [-Wzero-as-null-pointer-constant]
>     unictype/scripts_byname.gperf:160:10: warning: zero as null pointer 
> constant [-Wzero-as-null-pointer-constant]
>     uninorm/composition-table.gperf:995:10: warning: zero as null pointer 
> constant [-Wzero-as-null-pointer-constant]
>
> These can only be fixed with a new glibc release and a new gperf release.

Thanks for analysis!

> So, as things stand now, we can recommend the warning option to package
> maintainers. But I am not in favour of letting Gnulib enable it by default,
> since it will invariably lead to warnings (in the two cases mentioned above)
> that the maintainer cannot silence. Only once there have been glibc + gperf
> releases and we have waited 2 years until most maintainers have a system with
> these newer releases, will it make sense to enable it by default.

Gnulib could also check if glibc/gperf have been updated and enable the
warning for those builds, to allow us to catch the problem in CI/CD's
and be able to fix the problems earlier.

But indeed, it is simpler to ask maintainers to enable
-Wzero-as-null-pointer-constant in some CI/CD run and manually filter
out errors caused by glibc/gperf.  I will experiment with it, when I
have find a suitable GCC 15.x container image.

/Simon

Attachment: signature.asc
Description: PGP signature

Reply via email to