Opened 9 years ago
Closed 8 years ago
#9441 closed Patches (fixed)
SolarisStudio support
| Reported by: | Owned by: | Edward Diener | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | tti |
| Version: | Boost 1.55.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
Hi
The attached patch makes TTI work better with the "Sun" compiler (5.12). It reduces the test fails from 31 to 10, though of the failures that remain some seem to be caused by mysterious whitespace removal:
"test_vm_has_template_cp.hpp", line 24: Error: Expected "class" or "struct" before "classATemplate"
Setting BOOST_PP_VARIADIC=0 for all tests drop the failures to 8.
Of the remaining failures, most (all I think) seem to be caused by has_template.
Sadly I can't see a simple declaration-only sfinae helper struct in the template introspection code that could have the same mod applied to it, but given the BOOST_PP maybe I've missed it :) I'll have a play when I get some time, or if there's a simple non-BOOST_PP full example I'm happy to try to get that to work. In the meantime, I've attached the output of the remaining failures in case it's of any interest.
All tests still pass with gcc 4.8 on Linux.
Attachments (5)
Change History (14)
by , 9 years ago
| Attachment: | tti-sun.patch added |
|---|
comment:1 by , 9 years ago
OK so I had a play around with has_template_xxx with the Sun compiler.
BOOST_TTI_HAS_TEMPLATE(InnerTemplate, (1,(typename)))
Generates:
template < typename BOOST_TTI_DETAIL_TP_T, typename BOOST_TTI_DETAIL_TP_FALLBACK_ = Boost::mpl::bool_< false > >
class has_template_InnerTemplate_detail
{
template< typename U >
struct has_template_InnerTemplate_detail_introspect
{
template < template < typename > class BOOST_TTI_DETAIL_TM_V >
struct has_template_InnerTemplate_detail_substitute0
{
};
template< typename V > static Boost::mpl::aux::no_tag
has_template_InnerTemplate_detail_test(...);
template< typename V > static Boost::mpl::aux::yes_tag
has_template_InnerTemplate_detail_test( Boost::mpl::aux::type_wrapper< V > const volatile* , has_template_InnerTemplate_detail_substitute0 < V::template InnerTemplate > * = 0 );
static const bool value = sizeof(has_template_InnerTemplate_detail_test< U >(0)) == sizeof(Boost::mpl::aux::yes_tag);
typedef Boost::mpl::bool_< value > type;
};
public:
static const bool value = has_template_InnerTemplate_detail_introspect< BOOST_TTI_DETAIL_TP_T >::value;
typedef typename has_template_InnerTemplate_detail_introspect < BOOST_TTI_DETAIL_TP_T >::type type;
};
template<class BOOST_TTI_DETAIL_TP_T>
struct has_template_InnerTemplate : has_template_InnerTemplate_detail<BOOST_TTI_DETAIL_TP_T>
{
};
Two tweaks make this work:
- Using a nested type typedef within the substitute class (and appropriate change for the "yes" test function). Not unreasonable for any compiler I'd have thought.
- In the "yes" test function, using "U template::<template name>" rather than "V template::<template name>". This is obviously horribly broken on a non-broken compiler but seems to do the trick here...
Something like:
template < typename BOOST_TTI_DETAIL_TP_T, typename BOOST_TTI_DETAIL_TP_FALLBACK_ = Boost::mpl::bool_< false > >
class has_template_InnerTemplate_detail
{
template< typename U >
struct has_template_InnerTemplate_detail_introspect
{
template < template < typename > class BOOST_TTI_DETAIL_TM_V >
struct has_template_InnerTemplate_detail_substitute0
{
typedef void type;
};
template< typename V > static Boost::mpl::aux::no_tag
has_template_InnerTemplate_detail_test(...);
template< typename V > static Boost::mpl::aux::yes_tag
has_template_InnerTemplate_detail_test( Boost::mpl::aux::type_wrapper< V > const volatile* , typename has_template_InnerTemplate_detail_substitute0 < U::template InnerTemplate >::type* = 0 );
static const bool value = sizeof(has_template_InnerTemplate_detail_test< U >(0)) == sizeof(Boost::mpl::aux::yes_tag);
typedef Boost::mpl::bool_< value > type;
};
public:
static const bool value = has_template_InnerTemplate_detail_introspect< BOOST_TTI_DETAIL_TP_T >::value;
typedef typename has_template_InnerTemplate_detail_introspect < BOOST_TTI_DETAIL_TP_T >::type type;
};
template<class BOOST_TTI_DETAIL_TP_T>
struct has_template_InnerTemplate : has_template_InnerTemplate_detail<BOOST_TTI_DETAIL_TP_T>
{
};
I'll attach a patch (dtemplate_params.patch) that applies the above for the specific parameters case, since it's pretty easy to localize it to just that file (though not necessarily the "right" thing to do). The BOOST_PP_NIL case is a bit more of a problem as it's mostly mpl's has_xxx.hpp. I'll attach a patch for that also.
Tests still fail as the BOOST_PP_NIL usage with non-class template parameters actually works. I.e.
#include "boost/tti/has_template.hpp"
#include "boost/static_assert.hpp"
class Test
{
public:
template<typename T>
class InnerTTemplate
{
};
template<int C>
class InnerITemplate
{
};
};
class Test2
{
};
namespace Nil
{
BOOST_TTI_HAS_TEMPLATE(InnerTTemplate, BOOST_PP_NIL)
BOOST_TTI_HAS_TEMPLATE(InnerITemplate, BOOST_PP_NIL)
BOOST_STATIC_ASSERT((has_template_InnerTTemplate<Test>::value));
BOOST_STATIC_ASSERT((has_template_InnerITemplate<Test>::value));
BOOST_STATIC_ASSERT((!has_template_InnerTTemplate<Test2>::value));
BOOST_STATIC_ASSERT((!has_template_InnerITemplate<Test2>::value));
}
namespace Spec
{
BOOST_TTI_HAS_TEMPLATE(InnerTTemplate, (1,(typename)))
BOOST_TTI_HAS_TEMPLATE(InnerITemplate, (1,(int)))
BOOST_STATIC_ASSERT((has_template_InnerTTemplate<Test>::value));
BOOST_STATIC_ASSERT((has_template_InnerITemplate<Test>::value));
BOOST_STATIC_ASSERT((!has_template_InnerTTemplate<Test2>::value));
BOOST_STATIC_ASSERT((!has_template_InnerITemplate<Test2>::value));
}
int main()
{
return 0;
}
builds.
Anyway, I hope this is of some use, though it seems more of an mpl ticket at this point...
Regards
Luke Elliott.
by , 9 years ago
| Attachment: | dtemplate_params.patch added |
|---|
Hacks to dtemplate_params.hpp to allow specific parameters usage to work with Sun compiler.
by , 9 years ago
| Attachment: | has_xxx.patch added |
|---|
Hacks to mpl's has_xxx.hpp to allow BOOST_PP_NIL has_template_xxx to work with Sun compiler.
comment:2 by , 9 years ago
A fix for the bug in Boost MPL has been pushed to a separate git repository forked from the MPL 'develop' branch. The repository address is https://github.com/eldiener/mplsun.git. I will try to test this on Linux but I am not sure I have the correct Sun C++ compiler there to test it. If anybody can test this change for Sun CC for Boost MPL it will be appreciated. In the test, if the fix supplied is correct, there should be no errors when the Boost MPL has_xxx test is run using Sun CC with the fix in place if the fix supplied is correct.
I also modified the fix in has_xxx.2.patch, as applied to Boost MPL has_xxx.hpp so only code for Sun CC is changed. I was not about to change any of the other has_xxx.hpp code for any other compiler.
I will work on the fix for TTI next, but I would like to ascertain that the fix for Boost MPL has_xxx.hpp works correctly for Sun CC. This is because for BOOST_TTI_HAS_TYPE and the simpler cases of BOOST_TTI_HAS_TEMPLATE it uses the has_xxx implementation of Boost MPL internally.
comment:3 by , 9 years ago
Hi
No luck I'm afraid with the has_xxx test - it seems to get confused by the presence of something other than a template with the given name, and also
// agurt, 15/aug/04: make sure MWCW passes the test in presence of the following // template template< typename T > struct xxx;
Removing that leaves failures for
MPL_ASSERT_NOT(( has_xxx_template<a2> ));
MPL_ASSERT_NOT(( has_xxx_template<a3> ));
MPL_ASSERT_NOT(( has_xxx_template<a4> ));
and all the b2 tests.
Compiler too broken, I guess. Not sure if I'll get any more time to hack around, but if I do I'll post back anything I find. (For me right now the first patch with the member function introspection fixes etc. is all I need...)
Thanks
Luke.
comment:4 by , 9 years ago
I have pushed the Boost MPL fix to MPL on modular-boost now that I have write access to Boost MPL. It is on a branch of Boost MPL called 'mplsun'. I have also pushed the Boost TTI fixes to TTI on modular-boost in a branch of TTI called 'ttisun'. if anybody can test these changes for the Sun compiler on Linux that would be appreciated. The TTI change has the member function introspection fixes for the Sun compiler so hopefully that will be fixed. The issues with BOOST_TTI_HAS_TEMPLATE will probably not work since it relies on the MPL implementation, but can at least be tested. I will try to find some time to report the BOOST_TTI_HAS_TEMPLATE issues for the Sun compiler to Oracle. Perhaps they can upgrade the compiler in the future so that this MPL functionality, and the corresponding TTI functionality, will work.
comment:5 by , 9 years ago
I have tested the fixes with the Solaris Studio 12.3 product. The fixes fix all bugs except for the BOOST_TTI_HAS_TEMPLATE problem and the corresponding problem with the Boost MPL BOOST_MPL_HAS_XXX_TEMPLATE_DEF/BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF macros. I have inquired how I report this problem to Oracle, and will do so if I am able. I will merge the changes into the TTI developer branch shortly and 'push' those changes to the Boost repository on Github. They will be in the next release of Boost and, depending on where Boost id going with git, I may put out a separate release of TTI with these changes also.
I am pretty sure that until Oracle fixes the compiler problem that the HAS_TEMPLATE problem in MPL and TTI with the Sun compiler it will not be fixed. But if anyone has a viable workaround for that problem I will be glad to incorporate it in both MPL and TTI.
comment:6 by , 9 years ago
The fixes for the Sun compiler have now been merged into the 'develop' branch of tti in the modular-boost setup. I will merge them to release for the next version of Boost.
I reported the problems with template introspection in mpl and tti to Oracle on their C++ forum. It is now up to them to decide if they are going to fix these problems.
The rest of tti, outside of the class template introspection, should now work with the Sun compiler using the 'develop' branch of modular-boost.
comment:7 by , 9 years ago
I have just replied to your Oracle forums post (https://community.oracle.com/thread/2615211). The testcases you submitted there seem to be invalid to me.
Can you, please, check it out and verify that your SunC++ solution is appropriate?
comment:8 by , 8 years ago
The fix was merged into the master branch in late February and will go into Boost 1.56.
comment:9 by , 8 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |

Sun patches