On Fri, 28 Aug 2015, Martin Sebor wrote: > I ran into one regression in the gcc.dg/lto/pr54702_1.c test. > The file takes the address of malloc without declaring it, and > after calling it first. The code is invalid but GCC compiles it > due to a bug. I raised it in c/67386 -- missing diagnostic on > a use of an undeclared function, and suppressed the error by
But that PR isn't a bug - the code is working exactly as it's meant to (an implicit declaration acts exactly like an explicit declaration "int func ();" in the nearest containing scope). The declaration has an incompatible type, it's true, but GCC deliberately allows that with a warning. What if (a) you use a built-in function that returns int, instead of malloc, and (b) use -std=gnu89, so the implicit declaration isn't even an extension? Then you have something that's completely valid, including taking the address of the implicitly declared function. -- Joseph S. Myers jos...@codesourcery.com