This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++: -fstrict-prototypes problems
- To: gcc-bugs at gcc dot gnu dot org
- Subject: C++: -fstrict-prototypes problems
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Tue, 16 May 2000 00:54:19 +0200
- CC: <mark at codesourcery dot com>, ahrens at informatik dot hu-berlin dot de
Currently, g++ will reject the program
extern "C" void foo();
void foo(int);
int main()
{
foo();
}
It says
a.cc:2: too few arguments to function `void foo (int)'
a.cc:6: at this point in file
I think this is wrong, for a number of reasons:
- the documentation says that you can pass -pedantic to change the
behaviour. However, in this case, -pedantic should not apply:
-pedantic should make g++ only reject code which would be accepted
without it; in this case, -pedantic results in acceptance of code
which is rejected without it
- if this is an extension of g++ which gives a different meaning to
code under -ansi, then passing -ansi should enable the standard
behaviour, i.e. g++ should accept it. -ansi does not change
anything.
To have this code compile, you need to pass -fstrict-prototype. The
problem is that g++ considers the second declaration as a
redeclaration of the first, which it isn't.
I see a number of different solutions:
- Totally remove support for -fno-strict-prototype from g++.
- Toggle the setting of flag_strict_prototype, so people have to pass
-fno-strict-prototype to compile C++ code on systems where the system
headers don't offer proper prototypes.
- Don't treat the second declaration as a redeclaration of the first, even
with -fno-strict-prototype.
What do y'all think?
Regards,
Martin