https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112556

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <js...@gcc.gnu.org>:

https://gcc.gnu.org/g:3d525fce70fa0ffa0b22af6e213643e1ceca5ab5

commit r15-5431-g3d525fce70fa0ffa0b22af6e213643e1ceca5ab5
Author: Joseph Myers <josmy...@redhat.com>
Date:   Mon Nov 18 22:24:48 2024 +0000

    c: Allow bool and enum null pointer constants [PR112556]

    As reported in bug 112556, GCC wrongly rejects conversion of null
    pointer constants with bool or enum type to pointers in
    convert_for_assignment (assignment, initialization, argument passing,
    return).  Fix the code there to allow BOOLEAN_TYPE and ENUMERAL_TYPE;
    it already allowed INTEGER_TYPE and BITINT_TYPE.

    This bug (together with -std=gnu23 meaning false has type bool rather
    than int) has in turn resulted in people thinking they need to fix
    code using false as a null pointer constant for C23 compatibility.
    While such a usage is certainly questionable, it has nothing to do
    with C23 compatibility and the right place for warnings about such
    usage is -Wzero-as-null-pointer-constant.  I think it would be
    appropriate to extend -Wzero-as-null-pointer-constant to cover
    BOOLEAN_TYPE, ENUMERAL_TYPE and BITINT_TYPE (in all the various
    contexts in which that option generates warnings), though this patch
    doesn't do anything about that option.

    Bootstrapped with no regressions for x86-64-pc-linux-gnu.

            PR c/112556

    gcc/c/
            * c-typeck.cc (convert_for_assignment): Allow conversion of
            ENUMERAL_TYPE and BOOLEAN_TYPE null pointer constants to pointers.

    gcc/testsuite/
            * gcc.dg/c11-null-pointer-constant-1.c,
            gcc.dg/c23-null-pointer-constant-1.c: New tests.

Reply via email to