Path: utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!apple!rutgers!njin!princeton!notecnirp!drh From: drh@notecnirp.Princeton.EDU (Dave Hanson) Newsgroups: gnu.gcc.bug Subject: linkage warnings Message-ID: <12477@princeton.Princeton.EDU> Date: 8 Oct 88 13:38:22 GMT Sender: news@princeton.Princeton.EDU Reply-To: drh@princeton.Princeton.EDU (Dave Hanson) Distribution: gnu Organization: Dept. of Computer Science, Princeton University Lines: 37 after much reading of the 5/88 standard and K&R2, and discussions with others here and at bell labs, i think the convoluted explanations of linkage boil down to ``first declaration determines linkage''. thus, the following program specifies inconsistent linkage for both f and g. [709] cat bug4.c extern int f(); int g(); static f() {} static g() {} gcc doesn't complain: [710] gcc -v -S bug4.c gcc version 1.28 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dvax -Dunix bug4.c /tmp/cc028903.cpp GNU CPP version 1.28 /usr/local/lib/gcc-cc1 /tmp/cc028903.cpp -quiet -dumpbase bug4.c -version -o bug4.s GNU C version 1.28 (vax) compiled by GNU C version 1.28. it should ellicit at least a warning, e.g. [711] lcc -S bug4.c bug4.c:4.12:f(): warning: inconsistent linkage for f bug4.c:5.12:g(): warning: inconsistent linkage for g i note that gcc does warn about other linkage errors, e.g. f() { extern int x;} static int x; draws At top level: bug3.c:2: warning: `x' was declared `extern' and later `static'