[cfe-dev] Using both OpenCL and GCC vectors

Renato Golin via cfe-dev cfe-dev at lists.llvm.org
Fri Feb 5 13:58:17 PST 2016


Hi Douglas,

There's a big difference between acting on unambiguous scenarios and
"being smart". Compilers are generally safer if they don't do the
latter.


On 3 February 2016 at 03:33, Yung, Douglas via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> For example, the compiler could recognize that it is generating the same
> function when instantiating the second instance of foo and reuse the first
> one instead of creating another one. This would prevent the creation of two
> identically mangled names which caused the error seen above.

Why is this case more special than any other mangling conflict that
should correctly be refused?

What if I created a class that behaves *exactly* like a double and had:

foo<double>() {}
foo<MyDouble>() {}

would you expect the compiler to know what you mean?


> Or perhaps the
> compiler could be smarter and when it encounters the second instantiation of
> foo, it would issue an error at that point with a useful diagnostic.

That's a much better approach, but "being smart" again, is easy for
you to assess on your particular case, but harder for the compiler to
do the right thing (tm) on every case.

For me, it seems that this is just a case of also printing the origin
of the declaration when related to templates, since the user never
instantiates those functions anyway.

cheers,
--renato



More information about the cfe-dev mailing list