-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC C++ compliance: Using __builtin_offsetof #20229
Comments
Hi @JasonLunn, yes this is what we had in mind! One thing to address: Since MSVC is introducing a compiler error, we're worried that if customers upgrade MSVC, they might run into friction and need to regenerate their protobuf code. Is that the case here? And if so, what's protobuf's expectation for customers? Are compiler versions expected to be compatible with older generated protobuf code? Thank you for the quick response. |
@Radnyx Can you advise on when this change in behavior to MSVC might reach end users? Is there an expected version that it'll be included in? This isn't just about the generated code, but the "runtime" code too (for C++ we only support having an exact match between generated code and runtime version though so its a bit of an academic distinction in that case, but the difference is more relevant for other languages). It will help inform the discussion about potentially doing backported point releases with this change to older LTS versions, or if it would be expected that users would just need to use a sufficiently new Protobuf version to be compatible with that MSVC version. Thanks! |
@esrauchg No expected version as we'd like to measure the impact first. Still deciding whether to let users "opt-in" to the conformant behavior. We appreciate the willingness to either backport or expect users to upgrade. I'll message back shortly on our plan. |
Alrighty, thanks for your patience. We've decided not to add the error soon. Conformance there is still a future goal though. |
Hi folks,
This is in regard to the definition of
PROTOBUF_FIELD_OFFSET
:protobuf/src/google/protobuf/port_def.inc
Lines 311 to 314 in 0644388
The Visual C++ team found that this macro is supposed to cause a compiler error. It uses
reinterpret_cast
in constexpr statements, which isn't allowed by the standard. We intend to emit an error for this macro in future versions of MSVC.Fortunately, MSVC supports
__builtin_offsetof
, so we ask that you use that instead. Let me know if you have any questions.Thank you.
The text was updated successfully, but these errors were encountered: