home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!uunet.ca!frumious!pat
- From: pat@frumious.uucp (Patrick Smith)
- Subject: Re: defining cast operators outside classes
- Message-ID: <1992Sep9.003435.440@frumious.uucp>
- Date: Wed, 9 Sep 1992 00:34:35 GMT
- Reply-To: uunet.ca!frumious!pat
- References: <TMB.92Sep7162324@arolla.idiap.ch> <1992Sep8.173613.25113@taumet.com>
- Organization: None
- Lines: 46
-
- steve@taumet.com (Steve Clamage) writes:
- |The semantics depend on which non-class declarations are visible,
- |which is not normally the case in C++. (There is a somewhat
- |parallel case: You omit one overloaded function declaration and
- |an unintended function is called. Maybe someone can think of a way
- |to solve that problem in the language.)
-
-
- Here's one expensive, but I think otherwise reasonable, idea.
- This doesn't involve any changes to the language; the intent
- is for a compiler to produce appropriate warning messages.
-
-
- During compilation, the compiler would record the formal parameter
- types of every function (including inline functions, static functions,
- and functions declared but not defined). It would also record the
- actual argument types for every function call, and which function
- each call resolved to (compile-time resolution, so calls to virtual
- functions should resolve to the base class versions). All this
- information could perhaps be stored in the .o files or in files
- associated with the .o files.
-
- At a later point in time, perhaps while linking the executable,
- the compiler would scan the list of function calls, and determine
- which function each call would resolve to if all the functions
- declarations were visible at the point where the call was made.
- If the call resolves to a different function than earlier, or if
- the call is now ambiguous, then the compiler should issue a warning
- message.
-
- It is important to list all the functions declared, not just the
- ones defined. If a function is declared in places where it can't
- be used, but not declared in places where it could be used, then
- the linker might not include the function definition when linking
- the final program.
-
-
- I guess this is the sort of thing one might expect a C++ lint to do.
- As I said, it's probably quite expensive; I don't think I'd want it
- done on every compile. But it might be nice to have a compiler
- switch that would allow this checking to be requested occasionally.
-
- --
- Patrick Smith
- uunet.ca!frumious!pat
- pat%frumious.uucp@uunet.ca
-