[Patch] Fix binutils-gdb build with GCC 4.9 (was: Build problems with GIT version: ../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect)

Tobias Burnus tobias.burnus@physik.fu-berlin.de
Wed Jan 29 12:56:00 GMT 2014


Dear all,

GCC 4.9 (current GIT version) seems to warn now about
   bfd_set_section_userdata (stdoutput, seg, seginfo);
where the macro expands to "..., TRUE" (-Wunused-value)

And as binutils-gdb is compiled by default with "-Wall ... -Werror",
the build now fails.

That's fixed by the attached patch by adding (void) before those
'function' calls. (The macros are also called in context of "if(...)",
where the return value matters.)


Is the patch okay? If so, please commit. (It was tested by
building gdb into an empty directory.)


I haven't tried - but this patch or a very similar one probably
should do be added to the gdb 7.7 branch prior release. Maybe like
wise for binutils, depending how soon a branch release is planned
and whether also branches are build with -Werror.

Tobias


On Tue, Jan 28, 2014 at 09:25:17AM +0100, Tobias Burnus wrote:
> building the GIT version of binutils-gdb using GCC 4.9 fails as follows; it worked recently,
> albeit with a slightly older GCC 4.9.
> 
> The failure is:
> 
> make[4]: Entering directory `/data/local_users/tobiasb/gdb/binutils-gdb/build/gas'
> gcc -DHAVE_CONFIG_H -I. -I../../gas  -I. -I../../gas -I../bfd -I../../gas/config -I../../gas/../include -I../../gas/.. -I../../gas/../DIR="\"/data/local_users/tobiasb/gdb/gdb-inst/share/locale\""  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -gs.o -MD -MP -MF .deps/subsegs.Tpo -c -o subsegs.o ../../gas/subsegs.c
> In file included from ../../gas/as.h:95:0,
>                  from ../../gas/subsegs.c:25:
> ../../gas/subsegs.c: In function 'subseg_change':
> ../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
>  #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
>                                                                            ^
> ../../gas/subsegs.c:70:7: note: in expansion of macro 'bfd_set_section_userdata'
>        bfd_set_section_userdata (stdoutput, seg, seginfo);
>        ^
> ../../gas/subsegs.c: In function 'subseg_get':
> ../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
>  #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
>                                                                            ^
> ../../gas/subsegs.c:172:7: note: in expansion of macro 'bfd_set_section_userdata'
>        bfd_set_section_userdata (stdoutput, secptr, seginfo);
>        ^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-build.diff
Type: text/x-diff
Size: 7942 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20140129/54ad88d5/attachment.bin>


More information about the Binutils mailing list