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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 51799
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51799&action=edit
gcc12-pr102009.patch

Untested fix.
Unfortunately, this isn't the only spot in that file.  While e.g.
maybe_warn_nonstring_arg or pass_waccess::maybe_check_dealloc_call do punt if
nargs is too small, many other places don't care, e.g. look at
pass_waccess::check_strcat and most of following pass_waccess::check_* calls.
A quick way to fix it all is to punt if !gimple_builtin_call_types_compatible_p
between the builtin fndecl and the call stmt, but I vaguely remember Martin has
opposed against that.  So the other way is to at least check gimple_call_nargs
is sufficient for each builtin, and be prepared that an argument might have
completely different type too (e.g. floating point or structure rather than
expected pointer or size).

Reply via email to