From 3cc35adb6dca9057a790d253b9f5e2b9b000a106 Mon Sep 17 00:00:00 2001 From: Antal Tátrai Date: Sat, 5 Mar 2016 09:32:59 +0100 Subject: Fix compiling clang/libc++ builds. (Issue: #1266) --- src/google/protobuf/map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/google/protobuf/map.h') diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index dfc62420..9dd42572 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -548,7 +548,7 @@ class Map { !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) template void construct(NodeType* p, Args&&... args) { - new (static_cast(p)) NodeType(std::forward(args)...); + new (const_cast(static_cast(p))) NodeType(std::forward(args)...); } template -- cgit v1.2.3 From e2fb1d982291bfc87693d8a0744213ef22a75c14 Mon Sep 17 00:00:00 2001 From: Antal Tátrai Date: Tue, 8 Mar 2016 20:01:42 +0100 Subject: Comment has been added to fix (issue #1266) --- src/google/protobuf/map.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/google/protobuf/map.h') diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 9dd42572..37e19b0a 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -548,6 +548,10 @@ class Map { !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) template void construct(NodeType* p, 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(static_cast(p))) NodeType(std::forward(args)...); } -- cgit v1.2.3 From 58f07644eab25f68973ecab4bdc43fc318c26131 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 11 Mar 2016 09:19:58 -0800 Subject: Fixing compilation error when building with emscripten. This change was previously done in //third_party in CL 108656107 but never made it to the open source project and was overwritten in an update. --- src/google/protobuf/map.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/google/protobuf/map.h') diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 37e19b0a..83199380 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -545,7 +545,9 @@ class Map { } #if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ - !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) + !defined(GOOGLE_PROTOBUF_OS_NACL) && \ + !defined(GOOGLE_PROTOBUF_OS_ANDROID) && \ + !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) template void construct(NodeType* p, Args&&... args) { // Clang 3.6 doesn't compile static casting to void* directly. (Issue #1266) -- cgit v1.2.3