From 71b969dec9885b446470982cc1da8bc5232a12ce Mon Sep 17 00:00:00 2001 From: Andrew Foster Date: Mon, 10 Oct 2016 11:21:22 +0100 Subject: [PATCH 1/3] Fixed const_reverse_iterator compile error with Oracle Solaris Studio 12.1 Building Catch with Oracle Solaris Studio 12.1 generates an error because it is unable to convert from a std::vector<>::reverse_iterator to a std::vector<>::const_reverse_iterator. This is easily avoided by using a constant reference to the type before obtaining the iterator. --- include/internal/catch_run_context.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/internal/catch_run_context.hpp b/include/internal/catch_run_context.hpp index d37bdba1..c6a34906 100644 --- a/include/internal/catch_run_context.hpp +++ b/include/internal/catch_run_context.hpp @@ -327,8 +327,9 @@ namespace Catch { void handleUnfinishedSections() { // If sections ended prematurely due to an exception we stored their // infos here so we can tear them down outside the unwind process. - for( std::vector::const_reverse_iterator it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); + std::vector const& constUnfinishedSections = m_unfinishedSections; + for( std::vector::const_reverse_iterator it = constUnfinishedSections.rbegin(), + itEnd = constUnfinishedSections.rend(); it != itEnd; ++it ) sectionEnded( *it ); From 87803cdd2d2ebfcf53e03035ee5872fe4b054c64 Mon Sep 17 00:00:00 2001 From: Andrew Foster Date: Mon, 10 Oct 2016 11:27:32 +0100 Subject: [PATCH 2/3] Fixed std::make_pair compile error with Oracle Solaris Studio 12.1 Building Catch with Oracle Solaris Studio 12.1 generates an error when deducing a std::string argument from a const char * while constructing a std::pair<> via std::make_pair. Providing an explicit nudge to the compiler resolves the problem. --- include/internal/catch_tag_alias_registry.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/internal/catch_tag_alias_registry.hpp b/include/internal/catch_tag_alias_registry.hpp index e5ad11b2..ca85bd2e 100644 --- a/include/internal/catch_tag_alias_registry.hpp +++ b/include/internal/catch_tag_alias_registry.hpp @@ -48,7 +48,7 @@ namespace Catch { oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo; throw std::domain_error( oss.str().c_str() ); } - if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) { + if( !m_registry.insert( std::make_pair( std::string(alias), TagAlias( tag, lineInfo ) ) ).second ) { std::ostringstream oss; oss << "error: tag alias, \"" << alias << "\" already registered.\n" << "\tFirst seen at " << find(alias)->lineInfo << "\n" From 1f97d4d318c577b91bd6e95f2518a3e48c9758b4 Mon Sep 17 00:00:00 2001 From: Andrew Foster Date: Mon, 10 Oct 2016 11:34:19 +0100 Subject: [PATCH 3/3] Fixed std::distance compile error with Oracle Solaris Studio 12.1 Building Catch with Oracle Solaris Studio 12.1 generates an error when calling std::distance due to the toolchains non-compliant STL implementation. This implementation returns its result via an output parameter rather than a return value. --- include/internal/catch_compiler_capabilities.h | 10 ++++++++++ include/reporters/catch_reporter_compact.hpp | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h index 5af1e76a..3e64b202 100644 --- a/include/internal/catch_compiler_capabilities.h +++ b/include/internal/catch_compiler_capabilities.h @@ -119,6 +119,16 @@ #endif // _MSC_VER +//////////////////////////////////////////////////////////////////////////////// +// Oracle Solaris Studio +#ifdef __SUNPRO_CC + +# if __SUNPRO_CC == 0x5100 // Oracle Solaris Studio version 12.1 +# define CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL +# endif + +#endif // __SUNPRO_CC + //////////////////////////////////////////////////////////////////////////////// // Use variadic macros if the compiler supports them diff --git a/include/reporters/catch_reporter_compact.hpp b/include/reporters/catch_reporter_compact.hpp index a5a17297..2541f5d7 100644 --- a/include/reporters/catch_reporter_compact.hpp +++ b/include/reporters/catch_reporter_compact.hpp @@ -218,7 +218,12 @@ namespace Catch { // using messages.end() directly yields compilation error: std::vector::const_iterator itEnd = messages.end(); +# ifdef CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL + std::size_t N; + std::distance( itMessage, itEnd, N ); +# else const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); +# endif // CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL { Colour colourGuard( colour );