Fix presumed type clash in "ld
Fix presumed type clash in "ld - fix for bug 13343"
Hans-Peter Nilsson hans-peter.nilsson@axis.comSat Feb 18 04:20:00 GMT 2012
- Previous message (by thread): ld - fix for bug 13343
- Next message (by thread): Fix presumed type clash in "ld - fix for bug 13343"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> From: Alan Modra <amodra@gmail.com> > Date: Fri, 17 Feb 2012 15:13:47 +0100 > * ldmisc.c (vfinfo <%S>): Take file name and line number from > etree_type arg, or use current if arg is NULL. > Index: ld/ldmisc.c > @@ -240,12 +240,19 @@ vfinfo (FILE *fp, const char *fmt, va_li > > case 'S': > /* Print script file and linenumber. */ > - if (parsing_defsym) > - fprintf (fp, "--defsym %s", lex_string); > - else if (ldfile_input_filename != NULL) > - fprintf (fp, "%s:%u", ldfile_input_filename, lineno); > - else > - fprintf (fp, _("built in linker script:%u"), lineno); > + { > + node_type node; > + etree_type *tp = va_arg (arg, etree_type *); > + > + if (tp == NULL) > + { > + tp = (etree_type *) &node; > + tp->type.filename = ldlex_filename (); > + tp->type.lineno = lineno; > + } > + if (tp->type.filename != NULL) > + fprintf (fp, "%s:%u", tp->type.filename, tp->type.lineno)> ; > + } > break; This yields, for gcc-4.4.3 and 4.4.5 (but not for 4.1.2 nor 4.3.0): gcc -DHAVE_CONFIG_H -I. -I/tmp/hpautotest-gcc1/binusrc/src/ld -I. -I/tmp/hpautotest-gcc1/binusrc/src/ld -I../bfd -I/tmp/hpautotest-gcc1/binusrc/src/ld/../bfd -I/tmp/hpautotest-gcc1/binusrc/src/ld/../include -g -O2 -DENABLE_PLUGINS -DLOCALEDIR="\"/tmp/hpautotest-gcc1/cris-elf/pre/share/locale\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT ldmisc.o -MD -MP -MF .deps/ldmisc.Tpo -c -o ldmisc.o /tmp/hpautotest-gcc1/binusrc/src/ld/ldmisc.c cc1: warnings being treated as errors /tmp/hpautotest-gcc1/binusrc/src/ld/ldmisc.c: In function 'vfinfo': /tmp/hpautotest-gcc1/binusrc/src/ld/ldmisc.c:251: error: dereferencing pointer 'tp' does break strict-aliasing rules /tmp/hpautotest-gcc1/binusrc/src/ld/ldmisc.c:250: error: dereferencing pointer 'tp' does break strict-aliasing rules /tmp/hpautotest-gcc1/binusrc/src/ld/ldmisc.c:249: note: initialized from here make[4]: *** [ldmisc.o] Error 1 At least one of us should update the gcc used for development. :) Regardless of the validity of type-punning for a pointee that's actually a member in the union being the type pointed to, there are enough of gcc-4.4.3 and .5 out there that IMHO it makes sense to pacify them by making the code clearer. Or shorter, just say no to casts. Ok? ld: * ldmisc.c (vfinfo <%S>): Use same type and avoid cast for temporary variable node used for NULL argument. Index: ldmisc.c =================================================================== RCS file: /cvs/src/src/ld/ldmisc.c,v retrieving revision 1.41 diff -p -u -r1.41 ldmisc.c --- ldmisc.c 17 Feb 2012 14:09:57 -0000 1.41 +++ ldmisc.c 18 Feb 2012 04:07:15 -0000 @@ -241,12 +241,12 @@ vfinfo (FILE *fp, const char *fmt, va_li case 'S': /* Print script file and linenumber. */ { - node_type node; + etree_type node; etree_type *tp = va_arg (arg, etree_type *); if (tp == NULL) { - tp = (etree_type *) &node; + tp = &node; tp->type.filename = ldlex_filename (); tp->type.lineno = lineno; } brgds, H-P
- Previous message (by thread): ld - fix for bug 13343
- Next message (by thread): Fix presumed type clash in "ld - fix for bug 13343"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list