On 11/15/2021 1:31 PM, Martin Sebor via Gcc-patches wrote:
Declaring a function with a prototype at block scope and
then redeclaring it without a prototype at file scope results
in losing the prototype but not the attribute access that was
implicitly added to the function decl based on the prototype.
The middle end code that checks function calls for out-of-bounds
accesses based on the attribute is unprepared for this case and
fails with an ICE.  The attached patch corrects this by having
it ignore these pathological cases.  In addition, the change
also improves the format of the informational note printed
after these warnings to reflect the form of the argument
(e.g., to print int[7] rather than int * if the former was
the form used in the declaration).

Tested on x86_64-linux.

Martin

gcc-102759.diff

Avoid pathological function redeclarations when checking access sizes 
[PR102759].

Resolves:
PR tree-optimization/102759 - ICE: Segmentation fault in 
maybe_check_access_sizes since r12-2976-gb48d4e6818674898

        PR tree-optimization/102759

gcc/ChangeLog:

        PR tree-optimization/102759
        * gimple-array-bounds.cc (build_printable_array_type): Move...
        * gimple-ssa-warn-access.cc (build_printable_array_type): Avoid
        pathological function redeclarations that remove a previously
        declared prototype.
        Improve formatting of function arguments in informational notes.
        * pointer-query.cc (build_printable_array_type): ...to here.
        * pointer-query.h (build_printable_array_type): Declared.

gcc/testsuite/ChangeLog:

        PR tree-optimization/102759
        * gcc.dg/Warray-parameter-10.c: New test.
        * gcc.dg/Wstringop-overflow-82.c: New test.
OK
jeff

Reply via email to