Silence gcc-8 warnings
Jan Beulich
JBeulich@suse.com
Mon Apr 23 12:04:00 GMT 2018
>>> On 23.04.18 at 13:55, <amodra@gmail.com> wrote:
> On Mon, Apr 23, 2018 at 02:54:42AM -0600, Jan Beulich wrote:
>> >>> On 23.04.18 at 10:48, <amodra@gmail.com> wrote:
>> > --- a/bfd/elf-linux-core.h
>> > +++ b/bfd/elf-linux-core.h
>> > @@ -69,8 +69,12 @@ swap_linux_prpsinfo32_ugid32_out
>> > bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
>> > bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
>> > bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
>> > +#pragma GCC diagnostic push
>> > +#pragma GCC diagnostic ignored "-Wpragmas"
>> > +#pragma GCC diagnostic ignored "-Wstringop-truncation"
>> > strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
>> > strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
>> > +#pragma GCC diagnostic pop
>> > }
>>
>> We've tried to use this approach in the Xen hypervisor sources too in at least
>> one place: Older gcc isn't happy about such #pragma-s inside functions. Sadly
>> we haven't found a neat alternative (yet).
>
> I did try with a few older gcc versions.. Obviously didn't try enough.
> What versions fail?
I can see it with 4.3.x.
> I wanted to avoid adding -Wno-stringop-truncation to the default build
> flags (with a configure test for gcc-8), but that seems to be the most
> reasonable option if my patch is going to make things worse.
Yeah, same here - globally disabling the warning is not an option at all
imo, and disabling it for an entire function seems bad as well.
Jan
More information about the Binutils
mailing list