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

v3.0.1 compile error in icc 16.0.4 #947

Closed
mark-99 opened this issue Jan 31, 2018 · 12 comments
Closed

v3.0.1 compile error in icc 16.0.4 #947

mark-99 opened this issue Jan 31, 2018 · 12 comments
Assignees
Labels
platform: icc related to Intel compiler solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@mark-99
Copy link

mark-99 commented Jan 31, 2018

While this is maybe a compiler defect in icc 16 (icc 17.0.5 worked ok), perhaps there's an easy fix. Note than json v2.x did not have this error.

Source line is GTEST macro:
EXPECT_EQ(j["name"], "Name");

json/3.0.1/include/nlohmann/json.hpp(4177): error: the generated default constructor for "nlohmann::detail::internal_iterator<nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>>" cannot be used in an initializer for its own data member
      internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it = {};
                                                                                 ^
          detected during:
            instantiation of class "nlohmann::detail::iter_impl<BasicJsonType> [with BasicJsonType=const nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>]" at line 376 of "googletest/1.7.0.1/include/gtest/gtest-printers.h"
            instantiation of "void testing::internal::DefaultPrintTo(testing::internal::IsContainer={int}, testing::internal::false_type, const C &, std::ostream *) [with C=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>]" at line 477 of "googletest/1.7.0.1/include/gtest/gtest-printers.h"
            instantiation of "void testing::internal::PrintTo(const T &, std::ostream *) [with T=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>]" at line 707 of "googletest/1.7.0.1/include/gtest/gtest-printers.h"
            instantiation of "void testing::internal::UniversalPrinter<T>::Print(const T &, std::ostream *) [with T=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>]" at line 856 of "googletest/1.7.0.1/include/gtest/gtest-printers.h"
            instantiation of "void testing::internal::UniversalPrint(const T &, std::ostream *) [with T=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>]" at line 784 of "googletest/1.7.0.1/include/gtest/gtest-printers.h"
            [ 2 instantiation contexts not shown ]
            instantiation of "std::string testing::internal::FormatForComparison<ToPrint, OtherOperand>::Format(const ToPrint &) [with ToPrint=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, OtherOperand=char [5]]" at line 351 of "googletest/1.7.0.1/include/gtest/gtest-printers.h"
            instantiation of "std::string testing::internal::FormatForComparisonFailureMessage(const T1 &, const T2 &) [with T1=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, T2=char [5]]" at line 1385 of "googletest/1.7.0.1/include/gtest/gtest.h"
            instantiation of "testing::AssertionResult testing::internal::CmpHelperEQFailure(const char *, const char *, const T1 &, const T2 &) [with T1=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, T2=char [5]]" at line 1403 of "googletest/1.7.0.1/include/gtest/gtest.h"
            instantiation of "testing::AssertionResult testing::internal::CmpHelperEQ(const char *, const char *, const T1 &, const T2 &) [with T1=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, T2=char [5]]" at line 1428 of "googletest/1.7.0.1/include/gtest/gtest.h"
            instantiation of "testing::AssertionResult testing::internal::EqHelper<lhs_is_null_literal>::Compare(const char *, const char *, const T1 &, const T2 &) [with lhs_is_null_literal=false, T1=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, T2=char [5]]" at line 74 of "hmd_lib/hmd_lib/utils/FusionToJson.t.cpp"
@nlohmann nlohmann added the platform: icc related to Intel compiler label Jan 31, 2018
@theodelrieu
Copy link
Contributor

Could you try editting the source file and replace the m_it = {} with m_it{}?

@mark-99
Copy link
Author

mark-99 commented Jan 31, 2018

Same :/

include/nlohmann/json.hpp(4177): error: the generated default constructor for "nlohmann::detail::internal_iterator<nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>>" cannot be used in an initializer for its own data member
      internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it{};

@mark-99
Copy link
Author

mark-99 commented Jan 31, 2018

Removing the {} entirely works however - does this type actually need explicit value-init? It looks like the fields would be initialized anyway.

@theodelrieu
Copy link
Contributor

Yep you're right, it does seem like an ICC bug, but we can simply remove the {}.

@nlohmann since this is a trivial fix, could it be part of 3.1.0?

@nlohmann
Copy link
Owner

nlohmann commented Jan 31, 2018

Would we also need

internal_iterator() = default;

in template<typename BasicJsonType> struct internal_iterator?

Edit: No, I don't think so.

@nlohmann nlohmann self-assigned this Jan 31, 2018
@nlohmann nlohmann added this to the Release 3.1.0 milestone Jan 31, 2018
@theodelrieu
Copy link
Contributor

I don't think this is needed.

nlohmann added a commit that referenced this issue Jan 31, 2018
@mark-99
Copy link
Author

mark-99 commented Jan 31, 2018

I don't think so... generally you only need that if the default ctor is not implicitly generated, e.g. due to the presence of another ctor with params, to force it to make one. It doesn't hurt, but the compiler will do it anyway.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jan 31, 2018
@nlohmann
Copy link
Owner

@mark-99 Could you please check whether the latest commit fixed the issue?

@mark-99
Copy link
Author

mark-99 commented Jan 31, 2018

I have 3.0.1 rather than HEAD so the line numbers are different, but yes this seems good:
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it;

Verified on icc 16.0.4, icc 17.0.5, gcc 5.4, gcc 6.3, clang 3.9, clang 4.0.

BTW do you have a timescale on v3.1 release? So I know whether to go to the trouble of patching the copy in our local package manager?

@nlohmann
Copy link
Owner

If @theodelrieu finishes #944 tomorrow morning, then the release could be made tomorrow evening. :)

@mark-99
Copy link
Author

mark-99 commented Jan 31, 2018

Awesome - thx.

@nlohmann
Copy link
Owner

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: icc related to Intel compiler solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants