On Thu, 2020-02-27 at 15:40 -0700, Martin Sebor wrote:
> GCC considers valid explicit declarations of built-ins whose return
> types match in their modes, even if the types themselves are
> incompatible (say integer and pointer of the same size).  This is
> more permissive than for argument types where a pointer/integer
> mismatch disqualifies the redeclaration.
> 
> With -Wextra enabled although -Wbuiltin-declaration-mismatch
> diagnoses these "benign" mismatches in return types the C front-end
> still considers the mismatched declaration one of the built-in.  That
> can lead to problems down the line when the middle attempts to do its
> own sanity checking based on some simple and reasonable notion of type
> compatibility (like a malloc kind of function returning a pointer).
> 
> The attached patch tightens up the requirements a declaration has to
> meet in order to match a built-in to apply the same matching to their
> return types as to their arguments.
> 
> Tested on x86_64-linux.
> 
> Martin
> PR middle-end/93926 - ICE on a built-in redeclaration returning an integer
> instead of a pointer
> 
> gcc/c/ChangeLog:
> 
>       PR middle-end/93926
>       * c-decl.c (types_close_enough_to_match): New function.
>       (match_builtin_function_types):
>       (diagnose_mismatched_decls): Add missing inform call to a warning.
> 
> gcc/testsuite/ChangeLog:
> 
>       PR middle-end/93926
>       * gcc.dg/Wbuiltin-declaration-mismatch-13.c: New test.
OK
jeff

Reply via email to