diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-18 07:20:43 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-18 07:20:43 +0000 |
commit | 91218afc67773ebf85e37d91c80cb3a7d423b0ba (patch) | |
tree | a2f5a73a5a136924ae07064f366c22deefddf4a2 /src/google/protobuf/extension_set.cc | |
parent | 5e744ff9612da1add0dd0f893242703246c00d0c (diff) |
Fix Cygwin build.
Diffstat (limited to 'src/google/protobuf/extension_set.cc')
-rw-r--r-- | src/google/protobuf/extension_set.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index b1ffb0f5..615f33c7 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -120,7 +120,14 @@ void ExtensionSet::RegisterExtension(const MessageLite* containing_type, } static bool CallNoArgValidityFunc(const void* arg, int number) { - return reinterpret_cast<const EnumValidityFunc*>(arg)(number); + // Note: Must use C-style cast here rather than reinterpret_cast because + // the C++ standard at one point did not allow casts between function and + // data pointers and some compilers enforce this for C++-style casts. No + // compiler enforces it for C-style casts since lots of C-style code has + // relied on these kinds of casts for a long time, despite being + // technically undefined. See: + // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195 + return ((const EnumValidityFunc*)arg)(number); } void ExtensionSet::RegisterEnumExtension(const MessageLite* containing_type, @@ -130,7 +137,8 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* containing_type, GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM); ExtensionInfo info(type, is_repeated, is_packed); info.enum_is_valid = CallNoArgValidityFunc; - info.enum_is_valid_arg = reinterpret_cast<void*>(is_valid); + // See comment in CallNoArgValidityFunc() about why we use a c-style cast. + info.enum_is_valid_arg = (void*)is_valid; Register(containing_type, number, info); } |