Bug 68344 - No warning for old-style function declarations.
Summary: No warning for old-style function declarations.
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 5.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-13 21:42 UTC by i.hamsa
Modified: 2015-11-16 10:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description i.hamsa 2015-11-13 21:42:19 UTC
The following minimal test case

    int a();

generates no warning when -Wold-style-declaration -std=c11 is specified.

It is expected that a warning should be produced.

The manual at https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html says:

-Wold-style-declaration
    Warn for obsolescent usages, according to the C Standard, in a declaration

The C11 draft standard says:
    6.11.6 Function declarators
    The use of function declarators with empty parentheses (not prototype-
    format parameter type declarators) is an obsolescent feature.

===
Information about the compiler:

* output of gcc -v
Using built-in specs.
COLLECT_GCC=gcc-5.2.0
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-5.2.0/work/gcc-5.2.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/5.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/include/g++-v5 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/5.2.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 5.2.0 p1.0, pie-0.6.3' --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --enable-lto --without-isl --enable-libsanitizer
Thread model: posix
gcc version 5.2.0 (Gentoo 5.2.0 p1.0, pie-0.6.3)
Comment 1 Eric Gallager 2015-11-14 18:41:14 UTC
I think -Wstrict-prototypes does what you're looking for here:

$ /usr/local/bin/gcc -Wold-style-declaration -Wold-style-definition -Wstrict-prototypes -Wmissing-parameter-type -Wmissing-prototypes -std=c11 -pedantic -c pr68344.c
pr68344.c:1:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
 int a();
 ^
Comment 2 i.hamsa 2015-11-14 18:54:14 UTC
Indeed. I somehow missed that option. It probably would be logical for -Wold-style-declaration to imply -Wstrict-prototypes, but this is a minor issue.
Comment 3 Marek Polacek 2015-11-16 10:41:07 UTC
Resolved.