Skip to content

Compiling with icpc #755

Closed
Closed

Description

@tdegeus

I would like to compile with the Intel C++ compiler, in particular this one

$ icpc --version
icpc (ICC) 17.0.2 20170213
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

But currently this results in

...json.hpp(67): error: #error directive: "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
          #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"

When I remove the checks, I'm able to successfully compile and run. Compiling with -Wall -Wextra -pendantic only results in the following warnings

/home/tdegeus/prog/research/avalanches_inertia/json/json.hpp(6323): warning #186: pointless comparison of unsigned integer with zero
          return ((0 <= u and u <= 127) ? 0
                     ^
          detected during:
            instantiation of "std::size_t={unsigned long} nlohmann::detail::serializer<BasicJsonType>::extra_space(const nlohmann::detail::serializer<BasicJsonType>::string_t &, bool) [with BasicJsonType=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 6500
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump_escaped(const nlohmann::detail::serializer<BasicJsonType>::string_t &, bool) const [with BasicJsonType=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 6154
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType &, bool, bool, unsigned int, unsigned int) [with BasicJsonType=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 8995
            instantiation of "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::dump(int, char, bool) const [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool,
                      NumberIntegerType=int64_t={long}, NumberUnsignedType=uint64_t={unsigned long}, NumberFloatType=double, AllocatorType=std::allocator, JSONSerializer=nlohmann::adl_serializer]" at line 14653

/home/tdegeus/prog/research/avalanches_inertia/json/json.hpp(6663): warning #186: pointless comparison of unsigned integer with zero
          const bool is_negative = x < 0;
                                     ^
          detected during:
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump_integer(NumberType) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, NumberType=uint64_t={unsigned long}, <unnamed>=0]" at line 6290
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType &, bool, bool, unsigned int, unsigned int) [with BasicJsonType=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 8995
            instantiation of "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::dump(int, char, bool) const [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool,
                      NumberIntegerType=int64_t={long}, NumberUnsignedType=uint64_t={unsigned long}, NumberFloatType=double, AllocatorType=std::allocator, JSONSerializer=nlohmann::adl_serializer]" at line 14653

/home/tdegeus/prog/research/avalanches_inertia/json/json.hpp(9762): warning #191: type qualifier is meaningless on cast type
          return get_impl_ptr(static_cast<const PointerType>(nullptr));
                                          ^
          detected during:
            instantiation of "void nlohmann::detail::get_arithmetic_value(const BasicJsonType &, ArithmeticType &) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, ArithmeticType=double, <unnamed>=0]" at line 1133
            instantiation of "void nlohmann::detail::from_json(const BasicJsonType &, BasicJsonType::number_float_t &) [with BasicJsonType=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 1368
            instantiation of "auto nlohmann::detail::from_json_fn::call(const BasicJsonType &, T &, nlohmann::detail::priority_tag<1U>) const->decltype((<expression>)) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, T=double]" at line 1383
            instantiation of "void nlohmann::detail::from_json_fn::operator()(const BasicJsonType &, T &) const [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, T=double]" at line 6880
            instantiation of "void nlohmann::adl_serializer<<unnamed>, <unnamed>>::from_json(BasicJsonType &&, ValueType &) [with <unnamed>=double, <unnamed>=void, 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> &, ValueType=double]" at line 9592
            instantiation of "ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get<ValueTypeCV,ValueType,<unnamed>>() const [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool, NumberIntegerType=int64_t={long}, NumberUnsignedType=uint64_t={unsigned long}, NumberFloatType=double, AllocatorType=std::allocator,
                      JSONSerializer=nlohmann::adl_serializer, ValueTypeCV=double, ValueType=double, <unnamed>=0]" at line 237 of "/home/tdegeus/prog/research/avalanches_inertia/main.cpp"

remark #11074: Inlining inhibited by limit max-size
remark #11074: Inlining inhibited by limit max-total-size
remark #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo

Activity

  1. nlohmann commented on Sep 29, 2017

    @nlohmann
    Owner

    Thanks for reporting! I shall have a look at the warnings.

    Apparently, we seem to "recognize" a GCC here. Could you please post the output of the json::meta() function? If the Intel Compiler is correctly recognized there, I may have an idea how to fix the compiler detection above.

  2. self-assigned this
    on Sep 29, 2017
  3. tdegeus commented on Sep 29, 2017

    @tdegeus
    Author

    Here is the output of json::meta():

    {
        "compiler": {
            "c++": "201103",
            "family": "icc",
            "version": 1700
        },
        "copyright": "(C) 2013-2017 Niels Lohmann",
        "name": "JSON for Modern C++",
        "platform": "linux",
        "url": "https://github.com/nlohmann/json",
        "version": {
            "major": 2,
            "minor": 1,
            "patch": 1,
            "string": "2.1.1"
        }
    }
  4. nlohmann commented on Sep 29, 2017

    @nlohmann
    Owner

    Thanks! I shall have a look. I maybe just need to exclude ICC from the GCC version check.

    By the way: do you know whether there is a free version of ICC so that I could use it in the CI test suite?

  5. added this to the Release 3.0.0 milestone on Sep 29, 2017
  6. tdegeus commented on Sep 29, 2017

    @tdegeus
    Author
  7. nlohmann commented on Oct 2, 2017

    @nlohmann
    Owner

    @tdegeus All but 1 warnings should be gone now. I tried to fix the last one, but ran into a compiler issue, see #761. Could you try the latest develop version please?

  8. tdegeus commented on Oct 2, 2017

    @tdegeus
    Author

    @nlohmann Great, thanks! I have compiled with the latest develop version. It works. As predicted the only compiler warning that remains is

    ...json/json.hpp(6663): warning #186: pointless comparison of unsigned integer with zero
              const bool is_negative = x < 0;
                                         ^
              detected during:
                instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump_integer(NumberType) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={long}, uint64_t={unsigned long}, double, std::allocator, nlohmann::adl_serializer>, NumberType=uint64_t={unsigned long}, <unnamed>=0]" at line 6290
                instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType &, bool, bool, unsigned int, unsigned int) [with BasicJsonType=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 8995
                instantiation of "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::dump(int, char, bool) const [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool,
                          NumberIntegerType=int64_t={long}, NumberUnsignedType=uint64_t={unsigned long}, NumberFloatType=double, AllocatorType=std::allocator, JSONSerializer=nlohmann::adl_serializer]" at line 14655
  9. nlohmann commented on Oct 2, 2017

    @nlohmann
    Owner

    Meanwhile, I tried to get ICC running on Travis (see https://travis-ci.org/nlohmann/json/jobs/282297971), but it fails to compile so far. Maybe someone has an idea how to fix this.

  10. gregmarr commented on Oct 2, 2017

    @gregmarr
    Contributor

    Maybe this would help:

    const bool is_negative = std::is_same<NumberType, number_integer_t>::value && (x < 0);
    
  11. nlohmann commented on Oct 2, 2017

    @nlohmann
    Owner

    @gregmarr Thanks!

  12. 6 remaining items

  13. added a commit that references this issue on Oct 4, 2017
  14. nlohmann commented on Oct 4, 2017

    @nlohmann
    Owner

    Thanks everybody!

  15. kaidokert commented on Jan 19, 2018

    @kaidokert
    Contributor

    Just FYI, gcc-5.2 reports on this:

    /opt/m/cbor/../ext/nlohmann _json/src/json.hpp:7047:43: error: logical 'and' of mutually exclusive tests is always false [-Werror=logical-op]
             const bool is_negative = (x <= 0) and (x != 0);  // see issue #755
    
  16. zakalibit commented on Aug 29, 2018

    @zakalibit

    I changed to this and it makes compiler happy

    const bool is_negative = !(x>=0);

  17. TedLyngmo commented on Nov 21, 2018

    @TedLyngmo
    Contributor

    Hi! I still have this issue (although with an old unsupported clang 3.3.1 based compiler) but I managed to remove the warning by creating these templates:

        template<typename NumberType, detail::enable_if_t<
                     std::is_same<NumberType, number_unsigned_t>::value, int> = 0>
        bool is_negative_integer(NumberType x) { return false; }
    
        template<typename NumberType, detail::enable_if_t<
                     std::is_same<NumberType, number_integer_t>::value, int> = 0>
        bool is_negative_integer(NumberType x) { return x<0; }
    

    and in dump_integer(NumberType x):

    const bool is_negative = is_negative_integer(x); // see issue #755 
    

    I don't know exactly where to put these templates to make a proper pull request. Right now I just put them above dump_integer() to try it out.

    Would a change like this break something else? If not, can someone help me to find the proper place for the templates and I'll make a pull request out of it.

  18. linked a pull request that will close this issueAdd build step for NVCC and fix a warning #3227on Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ 换网址