google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library

Home Page:https://flatbuffers.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[C++ / iccarm (IAR) / Flatbuffers 2.0.6] Span count_ is const, but operator= performs assignment

avaliente-bc opened this issue · comments

Hello,
I'm trying to use flatbuffers with IAR compiler for ARM (iccarm 9.20.4).
The compiler reports an error in stl_emulation.h:

count_ = other.count_;
      ^
"/build/_deps/flatbuffers-src/include/flatbuffers/stl_emulation.h",388  Error[Pe137]: 
          expression must be a modifiable lvalue

The issue comes from span::operator= method, defined as folowwing

  FLATBUFFERS_CONSTEXPR_CPP14 span &operator=(const span &other)
      FLATBUFFERS_NOEXCEPT {
    data_ = other.data_;
    count_ = other.count_;
  }

and count_ is declared as const size_type count_; so it cannot be modified.