-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed as not planned
Description
Bug Report
Describe the bug
The C++ generated out of the `onnx.proto' does not compile.
In file included from /usr/include/string.h:495,
from /usr/include/google/protobuf/stubs/port.h:38,
from /usr/include/google/protobuf/stubs/common.h:46,
from /home/kraiskil/stuff/onnx2c-build-release/onnx.pb.h:9,
from /home/kraiskil/stuff/onnx2c-build-release/onnx.pb.cc:4:
In function ‘void* memset(void*, int, size_t)’,
inlined from ‘void onnx::TensorProto_Segment::SharedCtor()’ at /home/kraiskil/stuff/onnx2c-build-release/onnx.pb.cc:5531:11,
inlined from ‘onnx::TensorProto_Segment::TensorProto_Segment()’ at /home/kraiskil/stuff/onnx2c-build-release/onnx.pb.cc:5516:13,
inlined from ‘void protobuf_onnx_2eproto::InitDefaultsTensorProto_Segment()’ at /home/kraiskil/stuff/onnx2c-build-release/onnx.pb.cc:5512:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: error: ‘void* __builtin_memset(void*, int, long unsigned int)’ offset [33, 40] from the object at ‘onnx::_TensorProto_Segment_default_instance_’ is out of the bounds of referenced subobject ‘onnx::TensorProto_Segment::begin_’ with type ‘long int’ at offset 24 [-Werror=array-bounds]
71 | return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the above, onnx is compiled as a subproject of onnx2c, but the failure seems to happen in the code from onnx.
System information
- Ubuntu 20.04, x86_64
- protoc v3.6.1
- gcc 9.4.0
Reproduction instructions
In onnx repo base directory:
protoc onnx/onnx.proto --cpp_out=.
gcc -c onnx/onnx.pb.cc -I. -O3 -Wall
NB: gcc -O0
does not show the warning
Expected behavior
Should compile without an 'out of bounds' warning.