aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xiaofeng@google.com>2016-03-08 11:15:24 -0800
committerGravatar Feng Xiao <xiaofeng@google.com>2016-03-08 11:15:24 -0800
commit48ebb29a8ec118bf6b9ee39f6be42b57321c099a (patch)
treec55154b71053f4349ea308ff6ff73fbd2713586f
parenta8db268d8f1686ace3789af01cef7f0c9c3b61e2 (diff)
parente2fb1d982291bfc87693d8a0744213ef22a75c14 (diff)
Merge pull request #1299 from tatraian/master
Fix compiling clang/libc++ builds. (Issue: #1266)
-rw-r--r--src/google/protobuf/map.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index dfc62420..37e19b0a 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -548,7 +548,11 @@ class Map {
!defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID)
template<class NodeType, class... Args>
void construct(NodeType* p, Args&&... args) {
- new (static_cast<void*>(p)) NodeType(std::forward<Args>(args)...);
+ // Clang 3.6 doesn't compile static casting to void* directly. (Issue #1266)
+ // According C++ standard 5.2.9/1: "The static_cast operator shall not cast
+ // away constness". So first the maybe const pointer is casted to const void* and
+ // after the const void* is const casted.
+ new (const_cast<void*>(static_cast<const void*>(p))) NodeType(std::forward<Args>(args)...);
}
template<class NodeType>