]> git.ipfire.org Git - thirdparty/gcc.git/commit
c-family: Fix up -Wsizeof-pointer-memaccess ICEs [PR117230]
authorJakub Jelinek <jakub@redhat.com>
Tue, 22 Oct 2024 18:30:41 +0000 (20:30 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 22 Oct 2024 18:30:41 +0000 (20:30 +0200)
commit5fd1c0c1b6968d55e3f997d67a4c149edf20c012
treeb6e0a9439195fd7ebb9f553735be8aff5a4209c1
parentf616bc412c820d1fe1211ab68873607d7bfe2709
c-family: Fix up -Wsizeof-pointer-memaccess ICEs [PR117230]

In the following testcases, we ICE on all 4 function calls.
The problem is using TYPE_PRECISION on vector types (but guess it
would be similarly problematic on structures/unions/arrays).
The test only differentiates between suggestion what to do, whether
to supply explicit size because sizeof (*p) for
{,{,un}signed }char *p is not very likely what the user want, or
dereferencing the pointer, so I think limiting that suggestion
to integral types is ok.

2024-10-22  Jakub Jelinek  <jakub@redhat.com>

PR c/117230
* c-warn.cc (sizeof_pointer_memaccess_warning): Only compare
TYPE_PRECISION of TREE_TYPE (type) to precision of char if
TREE_TYPE (type) is integral type.

* c-c++-common/Wsizeof-pointer-memaccess5.c: New test.
gcc/c-family/c-warn.cc
gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess5.c [new file with mode: 0644]