Re: how to disable warning from -flto link ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Your code contains a serious bug (buffer overflow) - don't you want to
get warned about that?

On 31.01.2018 10:41, Jay Foad wrote:
> See example below: I'm getting warnings emitted by the -flto link stage.
> I'd like to selectively disable these warnings in my build scripts, but the
> usual -Wno-* option doesn't seem to have any effect. Is it supposed to
> work? Is there another way to do it?
>
> Thanks,
> Jay.
>
> $ gcc --version
> gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> $ cat a.c
> #include <string.h>
> void a(char * x, int n) {
> memset(x, 0, n);
> }
> $ cat b.c
> void a(char *, int);
> int main() {
> char x[3];
> a(x, 4);
> }
> $ gcc -O3 -flto -c a.c b.c -Wno-stringop-overflow
> $ gcc -O3 -flto a.o b.o -Wno-stringop-overflow
> In function ‘memset’,
>     inlined from ‘main’ at a.c:3:2:
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:10: warning:
> ‘__builtin___memset_chk’ writing 4 bytes into a region of size 3 overflows
> the destination [-Wstringop-overflow=]
>    return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
>           ^





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux