[PATCH 2/5] C front end support to detect out-of-bounds accesses to array parameters

Martin Sebor msebor@gmail.com
Tue Aug 25 18:44:21 GMT 2020

Joseph, do you have any more comments on the rest of the most recent
revision of the patch?



On 8/19/20 6:09 PM, Joseph Myers wrote:
> On Wed, 19 Aug 2020, Martin Sebor via Gcc-patches wrote:
>>> I think you need a while loop there, not just an if, to account for the
>>> case of multiple consecutive cdk_attrs.  At least the GNU attribute syntax
>>>      direct-declarator:
>>> [...]
>>>        ( gnu-attributes[opt] declarator )
>>> should produce multiple consecutive cdk_attrs for each level of
>>> parentheses with attributes inside.
>> I had considered a loop but couldn't find a way to trigger what you
>> describe (or a test in the testsuite that would do it) so I didn't
>> use one.  I saw loops like that in other places but I couldn't get
>> even those to uncover such a test case.  Here's what I tried:
>>    #define A(N) __attribute__ ((aligned (N), may_alias))
>>    int n;
>>    void f (int (* A (2) A (4) (* A (2) A (4) (* A (2) A (4) [n])[n])));
>> Sequences of consecutive attributes are all chained together.
>> I've added the loop here but I have no test for it.  It would be
>> good to add one if it really is needed.
> The sort of thing I'm thinking of would be, where A is some attribute:
> void f (int (A (A (A arg))));
> (that example doesn't involve an array, but it illustrates the syntax I'd
> expect to produce multiple consecutive cdk_attrs).

More information about the Gcc-patches mailing list