This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: typedef vs. typename confusion



> > Guess what g++ does?  It allows use of non-declared functions, assuming
> > int, and gives a warning.  I think that it is time for this to go away,
> > because it is now more trouble than it's worth
> 
> How so?  There are still C libraries that people want to use with sloppy
> declarations in the headers.  I don't think this particular extension is
> problematic.

Pardon me for being blunt, but it most certainly is a huge pain in the ass.
It's my #1 annoyance at using g++.  I am affected by this problem almost
every day.

(One problem with g++ is that it is written in C, so that the maintainers
are sheltered from problems with the tool to a much greater extent than
the GNU C maintainers).

The reason is that it results in huge cascades of warnings in reponse to
typos.  Let's say I have a class that has eight constructors, but it so
happens that none takes an int.  Now let's say that I misspell the name of
a function, which is used as an argument to the constructor.  I not only
get a warning for the "implicitly declared function", but I get about 16
lines of warnings describing every possible constructor and how none of
them take an int.  Then there is another cascade of errors because I'm
probably passing a class object to that function and you can't do that
with a varargs function.  If the undeclared function were simply replaced by
an error node, there would be no cascade of warnings.  I've had cases
where a typo was introduced in a header file where thousands of warnings
were generated, for one error (I am *not* exaggerating: the number
literally exceeded 1000).  Worse, they are only warnings -- no error
occurs until the link.

C++ programmers know that they must declare functions.  If a name is
not defined, then 999 times out of 1000 it is a typo, not a function
that is deliberately left undeclared and assumed to be int.

The problem of C libraries is solved by a separate g++ extension, which
is a good one: an extern "C" function which is declared without a full
prototype is treated as a varargs function.  I am not advocating that
this extension be removed.  This means that a user of a C library needs
to declare the function's return type but need not declare the arguments.

> > gcc has around a million users.  You are one user.  Your personal needs
> > can be satisfied with "-pedantic" (at least, they could be if -pedantic
> > were fixed).
> 
> Fixed?

All I mean is that -pedantic is still a long way away from rigorously
checking ISO C++ conformance, simply because the standard is so new.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]