errno bug and gcc internal error

YONETANI Tomokazu qhwt+dfly at
Tue Jul 19 08:53:03 PDT 2005

I don't remember when this started, but ld on -devel dumps core
trying to link a .o file containing an errno declaration(djbdns for one):

$ cat a.c
extern int errno;
int main(void) {return errno;}

$ gcc -W -Wall a.c
/usr/libexec/binutils215/elf/ld: BFD 2.15 [DragonFly] 2004-05-17 assertion fail /home/source/dragonfly/current/src/gnu/usr.bin/binutils215/libbfd/../../../../contrib/binutils-2.15/bfd/elflink.c:6081
gcc: Internal error: Segmentation fault (program ld)
Please submit a full bug report.
See <URL:> for instructions.

I know this is a software error and I know how to handle this easily:

$ sed -i.bak 's/^[[:space:]]*extern[[:space:]]*int[[:space:]]*errno;/#include <errno.h>/' *.c

But I wonder if someone has any idea how to let gcc say something like
this instead:

`bzzzt, your software declares errno as an extern int, which is incorrect.'


More information about the Bugs mailing list