http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58154
Bug ID: 58154
Summary: if declaration and definition of a function differ in
scope, emit a warning
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: alexander.huemer at xx dot vu
Hi,
i just stumbled upon a piece of code like this:
static int foo(void);
int foo(void)
{
volatile int a = 3;
return a;
}
According to http://std.dkuug.dk/JTC1/SC22/open/n2620/n2620.txt --> 6.1.2.2 #7
the behavior in this situation is undefined.
If, within a translation unit, the same identifier
appears with both internal and external linkage, the
behavior is undefined.
Steps to Reproduce:
the code above goes into foo.c
$ gcc -Wall -Wextra -c foo.c
Actual Results:
gcc does not emit a warning when compiling with -Wall -Wextra.
Expected Results:
gcc should emit a warning when compiling such code.