https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123928
Bug ID: 123928
Summary: C front end: non-standard main signature is only a
warning under -Wall/-Wextra/-Wpedantic ; consider
upgrading severity or clarify intended behavior
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 220246428 at seu dot edu.cn
Target Milestone: ---
When compiling C11 code with common warning flags, GCC only emits a warning for
a clearly non-conforming main signature, while Clang rejects it as an error.
This difference can matter for automated tooling and test pipelines that treat
“compile failure” (non-zero exit) as a hard filter: with GCC the program may
still proceed further (or be treated as “accepted” unless -Werror is used),
whereas Clang fails early. I would like to confirm whether GCC’s behavior is
intentional and, if so, whether the documentation/messages should clarify it;
otherwise, consider upgrading the diagnostic severity under -Wpedantic (or
similar) to better match strict conformance expectations.
Minimal reproducer:
------------------------------------------------------------
int main(int argc, short argv) { return 0; }
Commands:
------------------------------------------------------------
gcc -std=c11 -fsyntax-only -Wall -Wextra -Wpedantic testcase.c
clang -std=c11 -fsyntax-only -Wall -Wextra -Wpedantic testcase.c
Observed:
------------------------------------------------------------
GCC: warning about the second parameter of main (compilation succeeds unless
-Werror / -pedantic-errors is used)
Clang: error that the second parameter of main must be of type 'char **'
(compilation fails)
Additional notes:
------------------------------------------------------------
- With `-pedantic-errors` or `-Werror` (or `-Werror=main`), GCC also turns this
into an error.
- This report is about the default severity choice under the flags above
(warning vs error). The diagnostic corresponds to GCC’s main-signature checking
(commonly associated with -Wmain).