This is an archive of the discontinued LLVM Phabricator instance.

Don't ask for the size of dependent integral types in template diffing
AbandonedPublic

Authored by rnk on Dec 9 2015, 10:34 AM.

Details

Reviewers
rtrieu
rsmith
Summary

In the following example, we end up diffing 'A<int, 0>' against 'A<>'.

template <typename SizeType = int, SizeType = 0> struct A {};
template <typename R = A<>> R bar();
A<> &foo() { return bar(); }

It appears that we end up comparing the default argument of
'SizeType = 0' against the instantiated argument of 'int = 0'. The type
of the default argument is still dependent at this point, and this patch
bails out of the comparison at that point.

The diagnostic we ultimately give is not that great, but maybe we can
live with it:

error: non-const lvalue reference to type 'A<[...], (no argument)>'
       cannot bind to a temporary of type 'A<[...], 0>'

Diff Detail

Event Timeline

rnk updated this revision to Diff 42316.Dec 9 2015, 10:34 AM
rnk retitled this revision from to Don't ask for the size of dependent integral types in template diffing.
rnk updated this object.
rnk added a reviewer: rsmith.
rnk added a subscriber: cfe-commits.
rnk added a reviewer: rtrieu.Dec 11 2015, 10:48 AM

Digging back through more history, I see that Richard added the call to getTypeSize in rL230603.

rtrieu edited edge metadata.Dec 11 2015, 12:49 PM

So there's three or four semi-related failures around this part template diffing. I'm investigating the best way to handle these bugs.

I've fixed this issue as part of the template type diffing refactoring. r257870 was the last of the refactoring, and includes your test case in it.

rnk abandoned this revision.Jan 15 2016, 2:14 PM

Thanks!