Page MenuHomePhabricator

[libcxx] Fix PR22771 - Support access control SFINAE in the library version of is_convertible.
ClosedPublic

Authored by EricWF on Mar 19 2015, 1:53 PM.

Details

Summary

Currently the conversion check does not take place in a context where access control SFINAE is applied. This patch changes the context of the test expression so that SFINAE occurs if access control does not permit the conversion.

Related bug: https://llvm.org/bugs/show_bug.cgi?id=22771

Diff Detail

Event Timeline

EricWF updated this revision to Diff 22299.Mar 19 2015, 1:53 PM
EricWF retitled this revision from to [libcxx] Fix PR22771 - Support access control SFINAE in the library version of is_convertible..
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added reviewers: mclow.lists, rsmith.
EricWF added a subscriber: Unknown Object (MLST).
emaste added a subscriber: emaste.Mar 26 2015, 8:43 AM

I'm part of the https://jenkins.freebsd.org continuous integration team,
and have been working with Dimitry Andric to test compiing FreeBSD-CURRENT
with gcc 4.9. I reported the original problem which Dimitry filed under PR22771.

I took your patch, and I can confirm that with it, I can compile libc++ with gcc 4.9

dim accepted this revision.Mar 28 2015, 8:52 AM
dim added a reviewer: dim.
dim added a subscriber: dim.

This revision fixes both the original std::pair based test case I submitted in PR22771, and Richard Smith's minimal std::is_convertible based test case. Thanks. :)

This revision is now accepted and ready to land.Mar 28 2015, 8:52 AM
dim added a comment.Mar 28 2015, 8:55 AM

Note: Richard's minimal test case still does not compile with gcc 4.7.4, but that may very well be a gcc 4.7.4 bug:

$ gcc47 -I /share/dim/src/libcxx/trunk/include -std=c++11 -c minimal.cpp
/share/dim/src/libcxx/trunk/include/type_traits: In instantiation of 'struct std::__1::__is_convertible<const X&, X, 0u, 0u>':
/share/dim/src/libcxx/trunk/include/type_traits:957:62:   required from 'struct std::__1::is_convertible<const X&, X>'
minimal.cpp:4:42:   required from here
minimal.cpp:3:11: error: 'X::X(const X&)' is private
In file included from minimal.cpp:2:0:
/share/dim/src/libcxx/trunk/include/type_traits:893:8: error: within this context
/share/dim/src/libcxx/trunk/include/type_traits: In instantiation of 'struct std::__1::__is_convertible_imp::__is_convertible_test<const X&, X, void>':
/share/dim/src/libcxx/trunk/include/type_traits:893:8:   required from 'struct std::__1::__is_convertible<const X&, X, 0u, 0u>'
/share/dim/src/libcxx/trunk/include/type_traits:957:62:   required from 'struct std::__1::is_convertible<const X&, X>'
minimal.cpp:4:42:   required from here
minimal.cpp:3:11: error: 'X::X(const X&)' is private
In file included from minimal.cpp:2:0:
/share/dim/src/libcxx/trunk/include/type_traits:859:1: error: within this context
/share/dim/src/libcxx/trunk/include/type_traits:851:28: error:   initializing argument 1 of 'void std::__1::__is_convertible_imp::__test_convert(_Tp) [with _Tp = X]'
minimal.cpp:3:11: error: 'X::X(const X&)' is private
In file included from minimal.cpp:2:0:
/share/dim/src/libcxx/trunk/include/type_traits:859:1: error: within this context
/share/dim/src/libcxx/trunk/include/type_traits:851:28: error:   initializing argument 1 of 'void std::__1::__is_convertible_imp::__test_convert(_Tp) [with _Tp = X]'

The other versions I tested with had no problems:

  • gcc48 (FreeBSD Ports Collection) 4.8.5 20150319 (prerelease)
  • gcc49 (FreeBSD Ports Collection) 4.9.3 20150318 (prerelease)
  • gcc5 (FreeBSD Ports Collection) 5.0.0 20150322 (experimental)

Thanks for the thorough review. I suspect that 4.7 doesn't yes support access control SFINAE.

EricWF closed this revision.Mar 30 2015, 8:25 AM