Skip to content

Commit

Permalink
Merge pull request protocolbuffers#1299 from tatraian/master
Browse files Browse the repository at this point in the history
Fix compiling clang/libc++ builds. (Issue: protocolbuffers#1266)
  • Loading branch information
xfxyjwf committed Mar 8, 2016
2 parents a8db268 + e2fb1d9 commit 48ebb29
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/google/protobuf/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 48ebb29

Please sign in to comment.