Canonical type nodes, or, comptypes considered harmful

Doug Gregor doug.gregor@gmail.com
Wed Nov 8 03:25:00 GMT 2006


On 11/7/06, Mike Stump <mrs@apple.com> wrote:
> Anyway, in C++, the entire template mechanism was rife with building
> up duplicates.  I'd propose that this problem can (and should be
> addressed) and that we can do it incrementally.  Start with a hello
> world, then in comptypes, check to see when it says yes, they are the
> same, but the address equality checker says they might not be the
> same, print a warning.  Fix the dup builders until no warnings.  Then
> rebuild the world and repeat.  :-)  Work can be checked in, as dups
> are eliminated.

It's a good plan.

Now, how much do we worry about the fact that we won't be printing
typedef names when we combine duplicate nodes? If we don't care, our
job is much easier. If we do care, then we need to introduce a system
for equivalence classes to keep those typedef names, which will
complicate matters a bit.

> I did an extensive investigation in this area years ago, templates
> were the worse offender at that time.  <int,int,char> !=
> <int,int,char> type stuff.

Templates also have the opposite problem, because they do some strange
sharing, e.g., X<T1> == X<T2> (where T1 and T2 are template type
parameters from different templates). It makes for some strange
diagnostics in ConceptGCC, but without concepts it doesn't seem
harmful.

Since we know that type canonicalization is incremental, could we work
toward type canonicalization in the GCC 4.3 time frame?

  Cheers,
  Doug



More information about the Gcc mailing list