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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:f4d6ea0c64bbbbe45add18294bfbd2ceb6512bbd

commit r11-8489-gf4d6ea0c64bbbbe45add18294bfbd2ceb6512bbd
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed May 19 12:05:30 2021 +0200

    builtins: Fix ICE with unprototyped builtin call [PR100576]

    For unprototyped builtins the checking we perform is only about whether
    the used argument is integral, pointer etc., not the exact precision.
    We emit a warning about the problem though:
    pr100576.c: In function âfooâ:
    pr100576.c:9:11: warning: implicit declaration of function âmemcmpâ
[-Wimplicit-function-declaration]
        9 |   int n = memcmp (p, v, b);
          |           ^~~~~~
    pr100576.c:1:1: note: include â<string.h>â or provide a declaration of
âmemcmpâ
      +++ |+#include <string.h>
        1 | /* PR middle-end/100576 */
    pr100576.c:9:25: warning: âmemcmpâ argument 3 type is âintâ where
âlong unsigned intâ is expected in a call to built-in function declared
without prototype
    +[-Wbuiltin-declaration-mismatch]
        9 |   int n = memcmp (p, v, b);
          |                         ^
    It means in the testcase below where the user incorrectly called memcmp
    with last argument int rather then size_t, the warning stuff in builtins.c
    ICEs because it compares a wide_int from such a bound with another wide_int
    which has precision of size_t/sizetype and wide_int asserts the compared
    wide_ints are compatible.

    Fixed by forcing the bound to have the right type.

    2021-05-19  Jakub Jelinek  <ja...@redhat.com>

            PR middle-end/100576
            * builtins.c (check_read_access): Convert bound to size_type_node
if
            non-NULL.

            * gcc.c-torture/compile/pr100576.c: New test.

    (cherry picked from commit e6683450f4a26dae7774be735a3429f48aee9565)

Reply via email to