This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/41789] New: -Wmissing prototypes: nested functions shouldn't produce warnings if defined before first use
- From: "gcczilla1 at achurch dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Oct 2009 02:49:50 -0000
- Subject: [Bug c/41789] New: -Wmissing prototypes: nested functions shouldn't produce warnings if defined before first use
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Currently, if one compiles with -Wmissing-prototypes, GCC will complain about a
nested function defined with no preceding prototype declaration, for example:
int foo(int a) {
auto int bar(int b) { return b; }
return bar(a);
}
According to bug 19635 comment #1, the "proper" way to do this is to explicitly
add a forward declaration:
int foo(int a) {
auto int bar(int b);
auto int bar(int b) { return b; }
return bar(a);
}
But this seems redundant to me, since the declaration is local to the enclosing
function and there's no danger of any external code calling the nested function
improperly. Would it be possible to have GCC treat nested functions like
file-scope static functions, and omit the missing prototype warning if the
function is properly defined (with auto) before its first use?
--
Summary: -Wmissing prototypes: nested functions shouldn't produce
warnings if defined before first use
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcczilla1 at achurch dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41789