From e3c807d4e752b477b707f5d021264faf9b127304 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Fri, 23 Jun 2017 12:56:44 -0700 Subject: Fix more implicit type conversions in public headers and generated code. --- src/google/protobuf/stubs/hash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/google/protobuf/stubs/hash.h') diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index be998b29..a997e04b 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -348,7 +348,7 @@ struct hash { inline size_t operator()(const char* str) const { size_t result = 0; for (; *str != '\0'; str++) { - result = 5 * result + *str; + result = 5 * result + static_cast(*str); } return result; } -- cgit v1.2.3 From 9ab7c73f7c989afa777a40ff2a7c5f0f138be22c Mon Sep 17 00:00:00 2001 From: Matt Hauck Date: Mon, 10 Jul 2017 16:43:18 -0700 Subject: Fix missing std::tr1::hash on GCC 4.1 (#2907) Rather than crashing on use (doh!) better to just declare this platform is missing a proper hash_map/hash_set implementation and use the std::map/std::set emulation. Fixes regression introduced by #1913 --- src/google/protobuf/stubs/hash.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/google/protobuf/stubs/hash.h') diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index a997e04b..5924de98 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -40,7 +40,6 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1 #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 -#define GOOGLE_PROTOBUF_HAVE_64BIT_HASH 1 // Use C++11 unordered_{map|set} if available. #if ((_LIBCPP_STD_VER >= 11) || \ @@ -93,8 +92,11 @@ # define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set # endif +// GCC <= 4.1 does not define std::tr1::hash for `long long int` or `long long unsigned int` # if __GNUC__ == 4 && __GNUC__MINOR__ <= 1 -# undef GOOGLE_PROTOBUF_HAVE_64BIT_HASH +# define GOOGLE_PROTOBUF_MISSING_HASH +# include +# include # endif // Version checks for MSC. -- cgit v1.2.3 From 81142e162b7eea2c3f3483a11ce13a7fb5c20b88 Mon Sep 17 00:00:00 2001 From: Brad Larson Date: Wed, 12 Jul 2017 14:45:19 -0500 Subject: Fix build when using -Werror=undef Correct a couple places where macros were being checked when they might not exist in some cases. Fixes #3356. --- src/google/protobuf/io/coded_stream.h | 2 +- src/google/protobuf/stubs/hash.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/google/protobuf/stubs/hash.h') diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 20d86143..9f1cf88c 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -1434,7 +1434,7 @@ inline bool CodedInputStream::IsFlat() const { } // namespace protobuf -#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) +#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) #pragma runtime_checks("c", restore) #endif // _MSC_VER && !defined(__INTEL_COMPILER) diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index 5924de98..612b5861 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -42,7 +42,7 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 // Use C++11 unordered_{map|set} if available. -#if ((_LIBCPP_STD_VER >= 11) || \ +#if ((defined(_LIBCPP_STD_VER) && _LIBCPP_STD_VER >= 11) || \ (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \ (__GLIBCXX__ > 20090421))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH -- cgit v1.2.3