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: Request for a compiler feature


From: Joe Buck <jbuck@synopsys.com>
>
>Warning: while 95% of the time, outputting the typedef types will be a
big
>improvement, there are a number of errors that the user will have
>difficulty resolving without seeing the expanded types.  These are
cases
>where the error is that a typedef is set to the wrong value; in this
case
>the true error will be hidden.  These types of errors are likely to
occur
>for people developing STL-compatible containers, or for some uses of
such
>containers.
>
>Example: I might accidentally write something like
>
>typedef pair<Key,const Value> MyMapType;
>
>and then later try to use this in conjunction with a map<Key,Value> --
the
>error is that Key should be const and Value non-const.  If I then get
>a bunch of errors about its use, it might take a bit of code-reading to
>track down the error (though maybe that code reading wouldn't be too
>difficult).

Suggestion: Emit the typedefs separately from the main error message.
Something like this:

  foo.cpp:123: Error: MyMapType and MyOtherMapType are incompatible
  foo.cpp:123: MyMapType is typedef for std::pair<Key, const Value>
  foo.cpp:123: MyOtherMapType is typedef for std::pair<Key, Value>

That gives you the clearer error messages in the common cases where the
types involved are complicated template instantiations (e.g.
std::string) but the details aren't relevant, but if you need to you can
still check that the types are what you thought they were.

--
Ross Smith ................................... mailto:ross.s@ihug.co.nz
.............. The Internet Group, Auckland, New Zealand ..............
  "Remember when we told you there was no future? Well, this is it."
                                                        -- Blank Reg




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