Lost line numbers

Marc Glisse marc.glisse@inria.fr
Sat Nov 24 06:24:00 GMT 2018


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



More information about the Gcc-help mailing list