danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
697 stars 160 forks source link

compile error with gcc 11.3.0 #473

Closed romange closed 8 months ago

romange commented 8 months ago

Describe the bug when running make on v0.172.1 I get compile error

In member function ‘void jsoncons::basic_bigint<Allocator>::resize(jsoncons::basic_bigint<Allocator>::size_type) [with Allocator = std::allocator<unsigned char>]’,
    inlined from ‘jsoncons::basic_bigint<Allocator>& jsoncons::basic_bigint<Allocator>::operator>>=(uint64_t) [with Allocator = std::allocator<unsigned char>]’ at /home/roman/projects/jsoncons/include/jsoncons/bigint.hpp:773:19,
    inlined from ‘void jsoncons::basic_bigint<Allocator>::unnormalize(jsoncons::basic_bigint<Allocator>&, int, int) const [with Allocator = std::allocator<unsigned char>]’ at /home/roman/projects/jsoncons/include/jsoncons/bigint.hpp:1561:17,
    inlined from ‘void jsoncons::basic_bigint<Allocator>::divide(jsoncons::basic_bigint<Allocator>, jsoncons::basic_bigint<Allocator>&, jsoncons::basic_bigint<Allocator>&, bool) const [with Allocator = std::allocator<unsigned char>]’ at /home/roman/projects/jsoncons/include/jsoncons/bigint.hpp:1425:24:
/home/roman/projects/jsoncons/include/jsoncons/bigint.hpp:516:18: error: ‘void* __builtin_memset(void*, int, long unsigned int)’ specified size between 18446744073441116168 and 18446744073709551615 may exceed maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  516 |             a[i] = 0;

make succeeds

Enumerate the steps to reproduce the bug

git checkout v0.172.1
mkdir build
cmake ..
make -j4

Include a small, self-contained example if possible

What compiler, architecture, and operating system?

What jsoncons library version?

danielaparker commented 8 months ago

Can you check if you still see this with the code on master? Thanks.

danielaparker commented 8 months ago

I believe this has been fixed.

romange commented 8 months ago

It has not been @danielaparker

image

danielaparker commented 8 months ago

Can you post this output as you did before so I can see the entire line?

Thanks, Daniel

romange commented 8 months ago

this is how I do it (from jsoncons project root):

on my machine:

docker run -it -v$(pwd):/src --rm ghcr.io/rikorose/gcc-cmake

in the container:

cd /src
mkdir build && cd build && cmake ..
make -j

the error:

In file included from /src/include/jsoncons/json_encoder.hpp:20,
                 from /src/include/jsoncons/pretty_print.hpp:19,
                 from /src/include/jsoncons/basic_json.hpp:29,
                 from /src/include/jsoncons/json.hpp:10,
                 from /src/test/corelib/src/json_type_traits_chrono_tests.cpp:5:
In member function 'void jsoncons::basic_bigint<Allocator>::resize(size_type) [with Allocator = std::allocator<unsigned char>]',
    inlined from 'jsoncons::basic_bigint<Allocator>& jsoncons::basic_bigint<Allocator>::operator>>=(uint64_t) [with Allocator = std::allocator<unsigned char>]' at /src/include/jsoncons/bigint.hpp:773:19,
    inlined from 'void jsoncons::basic_bigint<Allocator>::unnormalize(jsoncons::basic_bigint<Allocator>&, int, int) const [with Allocator = std::allocator<unsigned char>]' at /src/include/jsoncons/bigint.hpp:1561:17,
    inlined from 'void jsoncons::basic_bigint<Allocator>::divide(jsoncons::basic_bigint<Allocator>, jsoncons::basic_bigint<Allocator>&, jsoncons::basic_bigint<Allocator>&, bool) const [with Allocator = std::allocator<unsigned char>]' at /src/include/jsoncons/bigint.hpp:1425:24:
/src/include/jsoncons/bigint.hpp:516:18: error: 'void* __builtin_memset(void*, int, long unsigned int)' specified bound between 18446744073441116168 and 18446744073709551608 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  516 |             a[i] = 0;
      |             ~~~~~^~~
cc1plus: all warnings being treated as errors
make[2]: *** [test/CMakeFiles/unit_tests.dir/build.make:1490: test/CMakeFiles/unit_tests.dir/corelib/src/json_type_traits_chrono_tests.cpp.o] Error 1
danielaparker commented 8 months ago

@romange, I can't replicate this in my test environments, so I'm left with trying to conjecture what might cause your compiler to think there could be an issue. I've made a few changes on master, and would appreciate it if you could try running the tests for the code on master.

romange commented 8 months ago

Just checked it. The issue has disappeared.

danielaparker commented 8 months ago

Thanks!