-
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
Visual Studio 2017 CE error #4488
Comments
@MikeGarrod Which version or Git commit are you using? Does the full error message say something about what line in cpp_field.cc is causing the problem? |
My mistake, I pulled the latest Master, Release 3.5.1.1 does not have the same issue. Thanks |
@MikeGarrod No problem, I'm glad it's working for you now. |
The problematic code is the allocation of arrays of unique_ptr like in java_field.cc(214):
The code itself is not wrong but apparently triggers a bug in Visual C++ 2017 15.6 (see here). Although the VS bug was supposedly fixed already the problem still persists with the current VS 2017 15.6.6. |
@rcane Thanks for tracking down the problem! Do you think we should try to work around this or just wait for the compiler fix? I'm not really familiar with Visual Studio and so I'm not sure how their release process works. |
Good question. The bug was reported 4 month ago. They said they had it fixed three month ago. Since then there have been 6 service releases of VS 2017 15.6.x. And neither one of them contained the fix. So it might be in the next service release (which they do approximately every week) or it will come in the next minor release (which might come next month). So a workaround might not be such a bad idea. A possible workaround could be using a std::vector<std::unique_ptr<...>> instead of a the unique_ptr<unique_ptr []> construct for the various generator arrays. So for example in cpp_field.h change
into
And in the implementation the constructor needs to be changed from
to
The same pattern can be applied to java_field, java_file, and objectivec_field. Although this makes the all code compile I did not have the time to actually test it. |
That seems like a good idea. Aside from the compiler bug your change is nice anyway since it gets rid of the double unique_ptr indirection. Would you be interested in sending us a pull request for this? |
I can send you a pull request in the next couple of days. |
The current 15.6.x versions of Visual Studio 2017 contain a bug that prevent them from compiling the following construct under certain conditions: std::unique_ptr<std::unique_ptr<Foo> []> foos; This will fail to compile if Foo is an abstract class. To work-around the problem the whole construct was change into: std::vector<std::unique_ptr<Foo>> foos; This not only fixes the compiler error but is also more readable than previous version.
I sent the following pull request: #4517 |
Fixed a Visual Studio 2017 build error. (#4488)
@rcane Thanks for the pull request with the fix! |
The current 15.6.x versions of Visual Studio 2017 contain a bug that prevent them from compiling the following construct under certain conditions: std::unique_ptr<std::unique_ptr<Foo> []> foos; This will fail to compile if Foo is an abstract class. To work-around the problem the whole construct was change into: std::vector<std::unique_ptr<Foo>> foos; This not only fixes the compiler error but is also more readable than previous version.
After building a MSVC 2017 Solution file using
cmake -G "Visual Studio 15 2017 Win64" - DCMAKE_INSTALL_PREFIX=../../../../install ../..
I am getting a number of compilation errors in type_traits.cc at line 527, The offending code looks like
And the 6 errors all complain "A native array cannot contain this type"
Full error below... (There are actually 6 similar errors
Error C2728
'google::protobuf::compiler::cpp::FieldGenerator': a native array cannot contain this type (compiling source file D:\Dev\Libraries\protobuf\src\google\protobuf\compiler\cpp\cpp_field.cc)
Project: libprotoc
File: c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.13.26128\include\type_traits
Line: 525
I am pretty new to this project and was hoping that someone could point out what I am missing.
Thanks
The text was updated successfully, but these errors were encountered: