On 01/02/2018 04:02 PM, Martin Sebor wrote:
> In addition to assuming that built-in functions are called with
> the correct number of arguments (bug 83603), the restrict pass
> also assumes that they are called with arguments of the expected
> types.  When a built-in is declared with no prototype and called
> with arguments of the wrong type (such as memcpy (3, dst, ""))
> the pass crashes GCC with a SEGV.
> 
> The attached patch prevents invalid calls from being checked for
> -Wrestrict violations.  It's meant to be applied in conjunction
> with the patch for bug 83603:
>   https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00005.html
> 
> A separate fix is to have GCC issue a warning for declarations
> of built-ins with no prototype.  I opened bug 83656 to track this
> change request to the C front end (C++ already warns for this).
> 
> Another improvement is to also warn about calls with the wrong number
> or types of arguments when a built-in is declared without a prototype
> despite the first warning, similarly to what Clang does.  I opened
> bug 83657 to add this warning.
> 
> Martin
> 
> gcc-83655.diff
> 
> 
> PR tree-optimization/83655 - ICE on an invalid call to memcpy declared with 
> no prototype
> 
> gcc/testsuite/ChangeLog:
> 
>       PR tree-optimization/83655
>       * gcc.dg/Wrestrict-5.c: New test.
>       * c-c++-common/builtins.c: New test.
> 
> gcc/ChangeLog:
> 
>       PR tree-optimization/83655
>       * gimple-ssa-warn-restrict.c (wrestrict_dom_walker::check_call): 
Looks like your ChangeLog is incomplete.  OK with the completed
ChangeLog entry.

Jeff

Reply via email to