Lost line numbers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lost line numbers

NightStrike
What would cause gcc (8.1.0) to lose line numbers when printing out a warning?

$ gcc -O3 -g -c file.c -o file.o (followed by tons of -I's)
./file.h: In function 'fcn':
cc1: warning: '__builtin_memset' writing 72 bytes into a region of
size 52 overflows the destination [-Wstringop-overflow=]

Note that the function is pretty large, and there's no direct calls to
memset, so I'm guessing some optimization is converting a loop to a
memset or something.

I don't have a reduced case yet... I've got 30k lines I'm trying to
auto-shrink down.
Reply | Threaded
Open this post in threaded view
|

Re: Lost line numbers

Marc Glisse-6
On Fri, 23 Nov 2018, NightStrike wrote:

> What would cause gcc (8.1.0) to lose line numbers when printing out a warning?
>
> $ gcc -O3 -g -c file.c -o file.o (followed by tons of -I's)
> ./file.h: In function 'fcn':
> cc1: warning: '__builtin_memset' writing 72 bytes into a region of
> size 52 overflows the destination [-Wstringop-overflow=]
>
> Note that the function is pretty large, and there's no direct calls to
> memset, so I'm guessing some optimization is converting a loop to a
> memset or something.
>
> I don't have a reduced case yet... I've got 30k lines I'm trying to
> auto-shrink down.

int a[13];
void f(){
   for(int i=0;i<18;++i)
     a[i]=0;
}

$ gcc-snapshot a.c -O3 -S -Wno-aggressive-loop-optimizations
a.c: In function 'f':
cc1: warning: '__builtin_memset' writing 72 bytes into a region of size 52
overflows the destination [-Wstringop-overflow=]

This call to memset is generated in generate_memset_builtin in
tree-loop-distribution.c. One could try calling gimple_set_location using
for instance find_loop_location, or the location of the write.

--
Marc Glisse
Reply | Threaded
Open this post in threaded view
|

Re: Lost line numbers

Martin Sebor-2
On 11/23/18 11:24 PM, Marc Glisse wrote:

> On Fri, 23 Nov 2018, NightStrike wrote:
>
>> What would cause gcc (8.1.0) to lose line numbers when printing out a
>> warning?
>>
>> $ gcc -O3 -g -c file.c -o file.o (followed by tons of -I's)
>> ./file.h: In function 'fcn':
>> cc1: warning: '__builtin_memset' writing 72 bytes into a region of
>> size 52 overflows the destination [-Wstringop-overflow=]
>>
>> Note that the function is pretty large, and there's no direct calls to
>> memset, so I'm guessing some optimization is converting a loop to a
>> memset or something.
>>
>> I don't have a reduced case yet... I've got 30k lines I'm trying to
>> auto-shrink down.
>
> int a[13];
> void f(){
>    for(int i=0;i<18;++i)
>      a[i]=0;
> }
>
> $ gcc-snapshot a.c -O3 -S -Wno-aggressive-loop-optimizations
> a.c: In function 'f':
> cc1: warning: '__builtin_memset' writing 72 bytes into a region of size
> 52 overflows the destination [-Wstringop-overflow=]
>
> This call to memset is generated in generate_memset_builtin in
> tree-loop-distribution.c. One could try calling gimple_set_location
> using for instance find_loop_location, or the location of the write.

There are other instances where this problem can come up with
other warnings as well but I don't think we have test cases for
any of them in Bugzilla.  Can one of you please open a bug for
this one so we can track and fix it?

Thanks
Martin