Skip to content

"Class-memaccess" compilation error in test [C++, gcc 10.1.0, Flatbuffers 1.12.0/master] #5930

@bakinovsky-m

Description

@bakinovsky-m

Compilation is failing on tests when using gcc 10.1.0.

flatbuffers/tests/arrays_test_generated.h: In constructor ‘MyGame::Example::ArrayStruct::ArrayStruct(float, int8_t, int32_t)’:
flatbuffers/tests/arrays_test_generated.h:156:34: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct MyGame::Example::NestedStruct’; use assignment or value-initialization instead [-Werror=class-memaccess]
  156 |     std::memset(d_, 0, sizeof(d_));
      |                                  ^
flatbuffers/tests/arrays_test_generated.h:66:40: note: ‘struct MyGame::Example::NestedStruct’ declared here
   66 | FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) NestedStruct FLATBUFFERS_FINAL_CLASS {
      |                                        ^~~~~~~~~~~~

Master branch and v1.12.0 tag are affected, didn't test other tags

Setup

  • gcc 10.1.0
  • flatbuffers 1.12.0 or master

Reproducing

  • cd to flatbuffers folders
  • run:
$ mkdir build && cd build
$ cmake .. #FLATBUFFERS_BUILD_TESTS is enabled by default
$ cmake --build .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions