Repository navigation
Open
Description
With Visual Studio 15.3 which has just been released, enabling the /permissive- conformance switch results in build errors.
This switch is useful to adhere strictly to the C++ standard, and it also helps enforcing cross-platform compatibility, reducing the chance to write code that will build under VS but not under clang/gcc for example.
It seems MS have enforced stricter rules as this was building fine in VS 15.2.
The error(s) appear in example\cpp11\non_def_con_class.cpp:
non_def_con_class.cpp
\include\msgpack/v1/object_fwd.hpp(66): error C2039: 'value': is not a member of 'msgpack::v1::type'
\include\msgpack/v1/adaptor/detail/cpp11_define_map.hpp(22): note: see declaration of 'msgpack::v1::type'
\include\msgpack/v2/object_fwd.hpp(97): note: see reference to class template instantiation 'msgpack::v1::has_as<T>' being compiled
1> with
1> [
1> T=int
1> ]
example\cpp11\non_def_con_class.cpp(37): note: see reference to class template instantiation 'msgpack::v2::has_as<int>' being compiled
\include\msgpack/v1/object_fwd.hpp(66): error C2065: 'value': undeclared identifier
\include\msgpack/v1/object_fwd.hpp(66): error C2131: expression did not evaluate to a constant
\include\msgpack/v1/object_fwd.hpp(66): note: failure was caused by non-constant arguments or reference to a non-constant symbol
\include\msgpack/v1/object_fwd.hpp(66): note: see usage of 'value'
\include\msgpack/v2/object_fwd.hpp(98): error C2039: 'value': is not a member of 'msgpack::v2::type'
\include\msgpack/v2/adaptor/detail/cpp11_define_map_decl.hpp(19): note: see declaration of 'msgpack::v2::type'
\include\msgpack/v2/object_fwd.hpp(98): error C2065: 'value': undeclared identifier
\include\msgpack/v2/object_fwd.hpp(98): error C2131: expression did not evaluate to a constant
\include\msgpack/v2/object_fwd.hpp(98): note: failure was caused by non-constant arguments or reference to a non-constant symbol
\include\msgpack/v2/object_fwd.hpp(98): note: see usage of 'value'
example\cpp11\non_def_con_class.cpp(37): warning C4305: 'specialization': truncation from 'const bool *' to 'bool'
example\cpp11\non_def_con_class.cpp(37): error C2672: 'msgpack::v1::object::as': no matching overloaded function found
example\cpp11\non_def_con_class.cpp(37): error C2770: invalid explicit template argument(s) for 'std::enable_if<msgpack::v2::has_as<T>::value,T>::type msgpack::v1::object::as(void) const'
\include\msgpack/v1/object_fwd.hpp(121): note: see declaration of 'msgpack::v1::object::as'
1>Done building project "non_def_con_class.vcxproj" -- FAILED.
Metadata
Metadata
Assignees
Labels
No labels
Activity
redboltz commentedon Aug 16, 2017
@lmdsp , thank you for reporting the issue.
The error message indicates the following code is invalid.
include/msgpack/v1/object_fwd.hpp
https://github.com/msgpack/msgpack-c/blob/master/include/msgpack/v1/object_fwd.hpp#L65
However, the type
typeis defined in the line 65.Compiler doesn't use this one but tying to looking for
msgpack::v1::type.typeis defined as a namespace. Seemsgpack-c/include/msgpack/v2/adaptor/nil_decl.hpp
Line 21 in 87ff7e4
I think that the type
typeintroduced byusing type = decltype(check<T>(MSGPACK_NULLPTR));should be used.lmdsp commentedon Aug 16, 2017
@redboltz , thanks for your insight.
According to your remarks, fixing this would be a simple matter of replacing
with
I'll test this tomorrow, what do you think ?
redboltz commentedon Aug 16, 2017
@lmdsp , I installed Visual Studio 15.3 and got the same error.
I wrote a (maybe) minimal code that reproduces the problem.
See
I reported the issue to Microsoft (developers community).
I think that it is msvc's bug.
/permissive-is not implemented correctly.clang++ and g++ with
-pedanticoption doesn't report any errors.I think that it works. In my minimal example, if I replaced
namespace type {}withnamespace type2 {}, the error is disappeared.I'm waiting Microsoft (developers community)'s response. If it is a bug of MSVC, I don't want to modify the code.
redboltz commentedon Aug 16, 2017
The report title is
[C++] invalid name lookup if /permissive- is set.I couldn't get URL of the report. It is integrated to Visual Studio. If you vote the report from Visual Studio, the priority of the report might be higher.
lmdsp commentedon Aug 16, 2017
Thanks, I'm a bit ouf of my depth on this one - I suppose I could dig in through the standard papers to check the rules of precedence / priority of namespaces over typedefs to check.
I know MS have a history of sometimes 'interpreting' the standard in quite surprising ways, but lately the VS compiler team has done a great deal of work to improve conformance and stay up to date with the latest C++ 17.
Anyway I've upvoted your report so it hopefully draws some attention. There seems to be a few similar reports, so hopefully this will get fixed soon.
hiradyazdan commentedon Aug 11, 2023
Hi @redboltz I seem to be having a similar issue. I am trying to use msgpack-cxx through msgpack.hpp header (
#include <msgpack.hpp>) usingmsvc(VS 2022C++17) -Windows 10, tried both with or without boost, but then it throws compile errors on this specific file (i.e.object_fwd.hpp) for each version (v1, v2, v3):I tried both
cpp_masterbranch directly and the released pkgs (6.1.0&6.0.0).It basically complains about variadic or any other templates. My impression is you've added support for
C++11on vs2015 features as well asC++03for compatibility (noticed your fix for vs2015 and lower versions mentioned in #463). Also, followed up on the issue mentioned above as well as #199, #193 and #177, that's quite similar to mine, and even though I made sure/permisssive- conformanceswitch is disabled, the errors still pop up. So I am at loss in this. I'd appreciate if you could help figure out this issue.redboltz commentedon Aug 12, 2023
@hiradyazdan
I think that you can try the exact same step as
msgpack-c/.github/workflows/gha.yml
Lines 191 to 239 in df1d126
on msvc2022 and msvc2019. Then fill the result as follows:
If msvc2019 reports the C2988 error, then the next step is checking the difference between your environment and CI(success).
If msvc 2019 doesn't reports the C2988 error, but msvc2022 reports error, it could be msvc2022 degrate issue.
redboltz commentedon Aug 13, 2023
I know
checkis common name, but it is private member function template ofhas_asclass template intmsgpacknamespace. If it is not allowed, C++ naming rule could be destroyed. I guess that this is the tip of an iceberg.If I understand correctly, it is MSVC problem but not msgpack-c problem. Please consider reporting MSVC issue to somewhere (Microsoft forlum of official suport) with https://stackoverflow.com/help/minimal-reproducible-example.
redboltz commentedon Aug 13, 2023
Do you mean if someone include AssertionMacros.h, then all
checkthat is located after the header are replaced?For example,
redboltz commentedon Aug 13, 2023
I think that the macro definition of
AssertionMacros.hhas serious problem. It is very strange that requesting all other libraries to care for bad designed macro definition ofAssertionMacros.h.However, I consider a possible solution:
your_app.cpp
The concept is all your translation units ( .cpp files) include
msgpack.hppon the top of the file.If your code is not an application but a library, this approach should work too.
E.g.)
your_lib1.hpp
your_lib2.hpp
users_app.cpp
redboltz commentedon Aug 13, 2023
Ok, if you post the PR that replaces
checkwithcheck_, I would merge it.That's my final answer.
Here are my thoughts:
It is because my policy. Easy to fix is not related.
I don't want to help the bad code infration. At releast
AssertionMacros.hmacro definition is bad and arrogant.Because it requires changing the function name for all other libraries in the world that conflict the name. This issue is one example. This time, luckyly it is a private member function, but if it were public one, request change like the username "X" in twitter?
I don't accept its design. See C++ books. These kinds of macro is very bad practice. I think
AssertionMacros.hshould be fixed.I really expect the design of
AssertionMacros.hwould be fixed in the future.I've just checked similar issue is reported and found it.
https://forums.unrealengine.com/t/ue-macros-and-3rd-party-library-conflicts/397848/4
https://github.com/hiili/UnrealMacroNuke
redboltz commentedon Aug 13, 2023
Thank you for the comment. I know you are not
AssertionMacros.hdeveloper. We both a kind of victims.Please send some feedback to Unreal Engine to improve it, if you didn't send yet.