https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99163
Bug ID: 99163
Summary: Odd error message when using `main` with
-pedantic-errors
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int main()
{
main();
}
With -pedantic-errors, this results in this error message:
error: ISO C++ forbids taking address of function ‘::main’ [-Wpedantic]
As far as I am aware, function calls can be done without the function type
decaying to a function pointer type, so this isn't even pedantically accurate.
I believe GCC instead should give an error message alike to "error: ISO C++
forbids usage of main within a program" or something similar, instead of the
currently at least somewhat confusing error message (which had me convinced for
a few minutes that C++ implicitly decayed function types to function pointer
types before calling them until I checked the standard).