This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: bfd_abort vs. noreturn vs. _exit (noreturn vs. system headers)
- From: Jay K <jay dot krell at cornell dot edu>
- To: binutils <binutils at sourceware dot org>
- Date: Sat, 8 May 2010 05:37:39 +0000
- Subject: RE: bfd_abort vs. noreturn vs. _exit (noreturn vs. system headers)
Hm. This is a bigger problem. If I remove the annotation:
cc1: warnings being treated as errors
/src/binutils/src/bfd/reloc.c: In function 'bfd_get_reloc_size':
/src/binutils/src/bfd/reloc.c:445:1: error: control reaches end of non-void function
cc1: warnings being treated as errors
/src/binutils/src/bfd/libbfd.c: In function '_bfd_generic_get_section_contents_in_window':
/src/binutils/src/bfd/libbfd.c:912:1: error: control reaches end of non-void function
cc1: warnings being treated as errors
/src/binutils/src/bfd/dwarf2.c: In function 'read_address':
/src/binutils/src/bfd/dwarf2.c:608:1: error: control reaches end of non-void function
Because these functions end with abort().
I'm trying assert(0); return 0; and that seems to "work", but then the quality of the
diagnostic might degrade.
?- Jay
----------------------------------------
> From: jay.krell@cornell.edu
> To: binutils@sourceware.org
> Subject: bfd_abort vs. noreturn vs. _exit
> Date: Sat, 8 May 2010 05:11:15 +0000
>
>
> /bin/sh ./libtool --tag=CC --mode=compile alpha-dec-vms-gcc -DHAVE_CONFIG_H -I. -I/src/binutils/src/bfd -DOSF_CORE -I. -I/src/binutils/src/bfd -I/src/binutils/src/bfd/../include -DBINDIR='"/usr/local/bin"' -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -MT bfd.lo -MD -MP -MF .deps/bfd.Tpo -c -o bfd.lo /src/binutils/src/bfd/bfd.c
> libtool: compile: alpha-dec-vms-gcc -DHAVE_CONFIG_H -I. -I/src/binutils/src/bfd -DOSF_CORE -I. -I/src/binutils/src/bfd -I/src/binutils/src/bfd/../include -DBINDIR=\"/usr/local/bin\" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -MT bfd.lo -MD -MP -MF .deps/bfd.Tpo -c /src/binutils/src/bfd/bfd.c -o bfd.obj
> cc1: warnings being treated as errors
> /src/binutils/src/bfd/bfd.c: In function '_bfd_abort':
> /src/binutils/src/bfd/bfd.c:944:1: error: 'noreturn' function does return
> make[2]: *** [bfd.lo] Error 1
> make[1]: *** [all-recursive] Error 1
> make: *** [all] Error 2
>
>
> libbfd-in.h:
> extern void _bfd_abort
> (const char *, int, const char *) ATTRIBUTE_NORETURN;
>
>
> bfd.c:
> void
> _bfd_abort (const char *file, int line, const char *fn)
> {
> if (fn != NULL)
> (*_bfd_error_handler)
> (_("BFD %s internal error, aborting at %s line %d in %s\n"),
> BFD_VERSION_STRING, file, line, fn);
> else
> (*_bfd_error_handler)
> (_("BFD %s internal error, aborting at %s line %d\n"),
> BFD_VERSION_STRING, file, line);
> (*_bfd_error_handler) (_("Please report this bug.\n"));
> _exit (EXIT_FAILURE);
> }
>
>
> I removed -Werror.
>
>
> /usr/local/alpha-dec-vms/include/unistd.h doesn't declare _exit with such an annotation.
> Possibly the native compiler has no such mechanism.
>
>
> build=darwin
> target=host=alpha-dec-vms
> gcc=4.5.0
>
>
> It seems to me there is a slight tension between portability and quality.
> Quality says to put in the attribute for slightly better compiler analysis/diagnostics.
> Portability says to remove it.
>
>
> - Jay
>