public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64526] New: No warning on function call with excessive arguments
@ 2015-01-07 18:56 chengniansun at gmail dot com
2015-01-07 19:02 ` [Bug c/64526] " rth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: chengniansun at gmail dot com @ 2015-01-07 18:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64526
Bug ID: 64526
Summary: No warning on function call with excessive arguments
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
GCC does not warn on the following function call to "fn1". The function "fn1"
is defined with no parameters. Based on the standard, the empty parameter list
in a function declarator that is part of a definition of that function
specifies that the function has no parameters.
$ cat test.c
void fn1 () {}
void fn2 (int p) { fn1 (p); }
$ gcc-trunk -Wall -Wextra -pedantic -std=c11 -c test.c
$ clang-trunk -c test.c
test.c:2:27: warning: too many arguments in call to 'fn1'
void fn2 (int p) { fn1 (p); }
~~~ ^
1 warning generated.
$
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/64526] No warning on function call with excessive arguments
2015-01-07 18:56 [Bug c/64526] New: No warning on function call with excessive arguments chengniansun at gmail dot com
@ 2015-01-07 19:02 ` rth at gcc dot gnu.org
2015-01-07 22:59 ` chengniansun at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rth at gcc dot gnu.org @ 2015-01-07 19:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64526
Richard Henderson <rth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |rth at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #1 from Richard Henderson <rth at gcc dot gnu.org> ---
Not a bug -- fn1 is not a function with no arguments,
but an unprototyped function. To get a function with
no arguments you must write
void fn1 (void) {}
This is C, not C++.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/64526] No warning on function call with excessive arguments
2015-01-07 18:56 [Bug c/64526] New: No warning on function call with excessive arguments chengniansun at gmail dot com
2015-01-07 19:02 ` [Bug c/64526] " rth at gcc dot gnu.org
@ 2015-01-07 22:59 ` chengniansun at gmail dot com
2015-01-08 16:25 ` rth at gcc dot gnu.org
2015-01-08 17:15 ` chengniansun at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: chengniansun at gmail dot com @ 2015-01-07 22:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64526
Chengnian Sun <chengniansun at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |---
--- Comment #2 from Chengnian Sun <chengniansun at gmail dot com> ---
(In reply to Richard Henderson from comment #1)
> Not a bug -- fn1 is not a function with no arguments,
> but an unprototyped function. To get a function with
> no arguments you must write
>
> void fn1 (void) {}
>
> This is C, not C++.
Thanks for your reply. But I am still puzzled by a paragraph in the standard
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf):
-------------- C11 standard, sec 6.7.6.3, page 134 --------------
14. An identifier list declares only the identifiers of the parameters
of the function. An empty list in a function declarator that is part of
a definition of that function specifies that the function has no
parameters. The empty list in a function declarator that is not part of
a definition of that function specifies that no information about
the number or types of the parameters is supplied.
------------------------- END -----------------------------------
So if I understand it correctly, the function "fn1" does not have any
parameters. Please kindly advise. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/64526] No warning on function call with excessive arguments
2015-01-07 18:56 [Bug c/64526] New: No warning on function call with excessive arguments chengniansun at gmail dot com
2015-01-07 19:02 ` [Bug c/64526] " rth at gcc dot gnu.org
2015-01-07 22:59 ` chengniansun at gmail dot com
@ 2015-01-08 16:25 ` rth at gcc dot gnu.org
2015-01-08 17:15 ` chengniansun at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: rth at gcc dot gnu.org @ 2015-01-08 16:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64526
Richard Henderson <rth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Richard Henderson <rth at gcc dot gnu.org> ---
Still invalid.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/64526] No warning on function call with excessive arguments
2015-01-07 18:56 [Bug c/64526] New: No warning on function call with excessive arguments chengniansun at gmail dot com
` (2 preceding siblings ...)
2015-01-08 16:25 ` rth at gcc dot gnu.org
@ 2015-01-08 17:15 ` chengniansun at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: chengniansun at gmail dot com @ 2015-01-08 17:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64526
--- Comment #5 from Chengnian Sun <chengniansun at gmail dot com> ---
(In reply to joseph@codesourcery.com from comment #3)
> "has no parameters" does not mean "has a type that includes a prototype
> with no parameters". See DR#317.
>
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_317.htm
Thanks for your pointer.
But from the perspective of diagnostics, I believe it is worthy to emit a
warning on this case, as the execution of the function call is undefined
according to the standard.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-08 17:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-07 18:56 [Bug c/64526] New: No warning on function call with excessive arguments chengniansun at gmail dot com
2015-01-07 19:02 ` [Bug c/64526] " rth at gcc dot gnu.org
2015-01-07 22:59 ` chengniansun at gmail dot com
2015-01-08 16:25 ` rth at gcc dot gnu.org
2015-01-08 17:15 ` chengniansun at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).