Skip to content
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

regression : [protobuf] generated code fails to compile with MSVC after upgrade to 3.25.1 with C2370 error #39459

Open
davidhunter22 opened this issue Jun 23, 2024 · 4 comments
Assignees
Labels
category:infrastructure Pertaining to the CI/Testing infrastrucutre

Comments

@davidhunter22
Copy link

davidhunter22 commented Jun 23, 2024

This is as much an information message to save other people trying to understand this issue.

The following PR was just merged #35781
This upgrades protobuf to version 3.25.1

This causes a regression for MSVC
The code in the protobuf package can't be compiled with the MSVC compiler.
The compiler issue is known and is described here https://developercommunity.visualstudio.com/t/c2370-is-falsely-emitted-when-a-static-const-membe/898167

There are a number of issues on the protobuf/grpc github related to this
protocolbuffers/protobuf#14602
grpc/grpc#35297

The suggested work around seem to be to add /permissive to your build which is sad. Even sadder the bug is in code in the generated header file so /permissive has to be specified in any including code.

Note the problematic code is only generated if you use a map field in your protobuf definition i.e. map<string,int>

@davidhunter22 davidhunter22 changed the title regression : protobuf generated code fails to compile after upgrade to 3.25.1 with C2370 error regression : protobuf generated code fails to compile with MSVC after upgrade to 3.25.1 with C2370 error Jun 23, 2024
@davidhunter22 davidhunter22 changed the title regression : protobuf generated code fails to compile with MSVC after upgrade to 3.25.1 with C2370 error regression : [protobuf] generated code fails to compile with MSVC after upgrade to 3.25.1 with C2370 error Jun 23, 2024
@WangWeiLin-MV WangWeiLin-MV added the category:infrastructure Pertaining to the CI/Testing infrastrucutre label Jun 24, 2024
@zlojvavan
Copy link

suggested workaround lead to an ICE for me, see this

@davidhunter22
Copy link
Author

davidhunter22 commented Jun 24, 2024

After some discussions I was informed that code that compiles in strict mode i.e /permissive- can fail to compile in lax mode i.e. /permissive. This means that using /permissive may not be a work around.
Note a "fix" for this has been implemented in Protobuf 26.0. See protocolbuffers/protobuf@f78f9c5 and related issue protocolbuffers/protobuf#14602
At present I don't know of a work around that always works for protobuf 25.0 and MSVC

@davidhunter22
Copy link
Author

davidhunter22 commented Jun 24, 2024

I just realized the problem is not in the code generated by the protoc compiler but in the map_field.h file in the package.

So a patch for this would be to change line 681 of map_field.h from
constexpr MapFieldBase::VTable
to
const MapFieldBase::VTable
at least for MSVC

Note this is exactly the change made by the patch protocolbuffers/protobuf@f78f9c5 in protobuf 2.6.0

jwcullen added a commit to AOMediaCodec/iamf-tools that referenced this issue Sep 4, 2024
  - See microsoft/vcpkg#39459 for details.
  - The fix, protocolbuffers/protobuf@f78f9c5, is not in any 25.x release.
  - Also, add a rule for `rules_python` to prevent regressions on Linux and Mac.

PiperOrigin-RevId: 670929662
@FangCunWuChang
Copy link

I hit this. It breaks my proto file generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:infrastructure Pertaining to the CI/Testing infrastrucutre
Projects
None yet
Development

No branches or pull requests

4 participants