On Tue, May 28, 2024 at 1:24 AM Andrew MacLeod <amacl...@redhat.com> wrote: > > The strlen pass currently has a local ranger instance, but when it > invokes SCEV or any other shared component, SCEV will not be able to > access to this ranger as it uses get_range_query(). They will be stuck > with global ranges. > > Enable/disable ranger should be used instead of a local version which > allows other components to use the current range_query. > > Bootstraps on 86_64-pc-linux-gnu, but there is one regression. The > regression is from gcc.dg/Wstringop-overflow-10.c. the function in > question: > > void > baz (char *a) > { > char b[16] = "abcdefg"; > __builtin_strncpy (a, b, __builtin_strnlen (b, 7)); /* { dg-bogus > "specified bound depends on the length of the source argument" } */ > } > > when compiled with -O2 -Wstringop-overflow -Wstringop-truncation > > it now spits out: > > b2.c: In function ‘baz’: > b2.c:24:3: warning: ‘__builtin_strncpy’ output 2 truncated before > terminating nul copying <unknown> bytes from a string of the same length > [-Wstringop-truncation] > 24 | __builtin_strncpy (a, b, __builtin_strnlen (b, 7)); /* { > dg-bogus "specified bound depends on the length of the source argument" } */ > > It seems like maybe something got smarter by setting the current range > query and this is a legitimate warning for this line of code? There > will indeed not be a NULL copied as there are 7 characters in the string... > > Is this a testcase issue where this warning should have been issued > before, or am I misunderstanding the warning?
I think the warning makes sense in this case. But I'm not sure why the dg-bogus is there, that looks like a valid complaint as well?! I think the patch is OK. Richard. > Andrew > > PS im afraid of adjusting the status quo in this pass... :-P Not > allowing sSCEV to access the current ranger is causing me other issues > with the fix for 115221. This *should* have been a harmless change > sigh. :-( The whole mechanism should just use the current range-query > instad of passing a ranger pointer aorund. But that a much bigger > issue. one thing at a time. > > >