[C++] Switch `flatc` to `--cpp-std c++11` C++ code generator (#6306)
authorVladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com>
Mon, 7 Dec 2020 19:19:36 +0000 (02:19 +0700)
committerGitHub <noreply@github.com>
Mon, 7 Dec 2020 19:19:36 +0000 (11:19 -0800)
commit7f33cf682a5d1150318806ef1ce1e6ee5cae146e
tree136437bc5eb59b501556758bdbbfb1e1c9a4cdb7
parent8d9eae9ac95c06ca1ae0139a8d80522163a17ae5
[C++] Switch `flatc` to `--cpp-std c++11` C++ code generator (#6306)

Prior to this commit the default C++ code generator was `c++0x`.
A code generated with `c++0x` code-gen might have a vulnerability (undefined behavior) connected evolution of enums in a schema. This UB could break the backward compatibility if previously generated code casts an unknown enumerator to enum type that knows nothing about future enumerators added to the schema.

The main differences between `c++0x` and `c++11`:

- generated enums use explicitly declared underlying type;
- generated object-API tables don't declare default ctor() explicitly, instead of it default data member initializers are generated.

Please use `flatc --cpp-std c++0x` option for backward compatibility with old compilers.
13 files changed:
docs/source/Compiler.md
samples/monster_generated.h
src/flatc.cpp
src/idl_gen_cpp.cpp
tests/arrays_test_generated.h
tests/monster_extra_generated.h
tests/monster_test_generated.h
tests/namespace_test/namespace_test1_generated.h
tests/namespace_test/namespace_test2_generated.h
tests/native_type_test_generated.h
tests/optional_scalars_generated.h
tests/test.cpp
tests/union_vector/union_vector_generated.h