This is an archive of the discontinued LLVM Phabricator instance.

Fix compile error for Visual Studio 2015 / cl compiler.
ClosedPublic

Authored by halyavin on Feb 1 2017, 4:03 AM.

Details

Reviewers
EricWF
Summary

Fix compile error for Visual Studio 2015 / cl compiler.
Visual Studio doesn't work well with constexpr function calls inside template arguments.

Add test for _PackExpandsToThisTuple check present in reduced arity constructors to improve their test coverage.

Event Timeline

halyavin created this revision.Feb 1 2017, 4:03 AM
EricWF edited edge metadata.Feb 1 2017, 9:03 AM

Test please.

halyavin retitled this revision from Fix compile error in tuple. to Fix compile error for Visual Studio 2015 / cl compiler..Feb 2 2017, 4:56 AM
halyavin edited the summary of this revision. (Show Details)

Ah, I see - there is no mistake here. It is Visual Studio 2015 cl compiler that doesn't have full support for constexpr function calls inside template arguments. I have substantially changed tuple header to avoid such calls and your revision just introduced another one.

Anyway, we should still apply this change for symmetry reasons, at least. What do you think?

EricWF added a comment.Feb 2 2017, 6:33 AM

The change is correct. It just needs a test.

Since there is no mistake here, I can't make the test to fail before the change. Or do you just need a test that invokes this code path? It looks like test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/disable_reduced_arity_initialization_extension.pass.cpp already does the job. If I replace !_PackExpandsToThisTuple<_Up...>() with false, it fails.

BTW, do I understand correctly, that this condition can't be true anyway since sizeof...(_Up) < sizeof...(_Tp)? I am now thinking about removing it altogether.

*this condition -> _PackExpandsToThisTuple<_Up...>

EricWF accepted this revision.Feb 2 2017, 10:15 PM

You're right. Sorry for being stupid.

This revision is now accepted and ready to land.Feb 2 2017, 10:15 PM
EricWF added a comment.EditedFeb 2 2017, 10:16 PM

BTW, do I understand correctly, that this condition can't be true anyway since sizeof...(_Up) < sizeof...(_Tp)? I am now thinking about removing it altogether.

What about for a tuple of 1 element?

Nevermind again.

halyavin updated this revision to Diff 86943.Feb 3 2017, 2:14 AM

Add test for _PackExpandsToThisTuple in reduce arity constructor.

halyavin edited the summary of this revision. (Show Details)Feb 3 2017, 2:17 AM

Ah, I misunderstood what _PackExpandsToThisTuple does. I added test that excises the case where it is needed.

halyavin edited the summary of this revision. (Show Details)Feb 3 2017, 7:02 AM

If you are satisfied with the test too, could you please commit this change for me?

EricWF added a comment.Feb 4 2017, 3:06 PM

The test looks great but I was mistaken about it being needed. We should already have the required tests. I incorrectly assumed that the bug caused that constructor to always drop out of overload resolution, so I thought it was untested. However this is not the case.

I'll commit the change to <tuple> but leave the test out. Sorry for the confusion and thanks for the patch.

EricWF closed this revision.Feb 4 2017, 3:08 PM

Committed in r294106.