From 660681a884c6fac23de5037f93c8720f66baecb3 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 13 Nov 2017 12:30:46 -0500 Subject: [PATCH] Fix SunCC 12.2 compile --- cryptlib.h | 10 +++++++++- integer.cpp | 11 ++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cryptlib.h b/cryptlib.h index a637901d..8e43d3af 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -471,6 +471,7 @@ ANONYMOUS_NAMESPACE_BEGIN const NullNameValuePairs s_nullNameValuePairs; ANONYMOUS_NAMESPACE_END +// Doxygen cannot handle initialization #if CRYPTOPP_DOXYGEN_PROCESSING //! \brief Default channel for BufferedTransformation //! \details DEFAULT_CHANNEL is equal to an empty string @@ -484,13 +485,20 @@ const std::string DEFAULT_CHANNEL; //! \details Crypto++ 6.0 placed AAD_CHANNEL in the header, rather than declaring it as extern and //! placing the definition in the source file. As an external definition the string AAD_CHANNEL //! was subject to static initialization order fiasco problems. -const std::string AAD_CHANNEL = "AAD"; +const std::string AAD_CHANNEL; //! \brief An empty set of name-value pairs //! \details Crypto++ 6.0 placed g_nullNameValuePairs in the header, rather than declaring it as extern //! and placing the definition in the source file. As an external definition the g_nullNameValuePairs //! was subject to static initialization order fiasco problems. const NameValuePairs g_nullNameValuePairs; + +// Sun Studio 12.3 and earlier can't handle NameValuePairs initialization +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5130) +static const std::string DEFAULT_CHANNEL; +static const std::string AAD_CHANNEL("AAD"); +static const NameValuePairs& g_nullNameValuePairs = s_nullNameValuePairs; + #else static const std::string DEFAULT_CHANNEL; static const std::string AAD_CHANNEL("AAD"); diff --git a/integer.cpp b/integer.cpp index 52644ffc..ef5c2b67 100644 --- a/integer.cpp +++ b/integer.cpp @@ -256,16 +256,17 @@ class DWord { public: #if defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) - DWord() : m_whole() { } + DWord() {std::memset(&m_whole, 0x00, sizeof(m_whole));} #else - DWord() : m_halfs() { } + DWord() {std::memset(&m_halfs, 0x00, sizeof(m_halfs));} #endif #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE explicit DWord(word low) : m_whole(low) { } #else - explicit DWord(word low) : m_halfs() + explicit DWord(word low) { + m_halfs.high = 0; m_halfs.low = low; } #endif @@ -279,10 +280,10 @@ public: #if defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) # if defined(CRYPTOPP_LITTLE_ENDIAN) const word t[2] = {low,high}; - memcpy(&m_whole, &t, sizeof(m_whole)); + memcpy(&m_whole, t, sizeof(m_whole)); # else const word t[2] = {high,low}; - memcpy(&m_whole, &t, sizeof(m_whole)); + memcpy(&m_whole, t, sizeof(m_whole)); # endif #else m_halfs.low = low;