mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
fix(string_stream): add missing initializations of const format specifiers (#849)
The const variables "left" and "right" are const default initialized. The C++ standard states the following: "A class type T is const-default-constructible if default-initialization of T would invoke a user-provided constructor of T." Since the "left_soec" and "right_spec" structs are PODs they are not initialized per default. Due to the "constness" the variable can not be modified later one, therefore the POD is in a state in which it is not useful at all. Since the mentioned structs are empty there would be no problem in this case. This is an issue in the C++ standard (CWG Issue 253). Some compilers already handle this issue with their own solution despite the fact, that the standard did not provide a solution yet. For some exotic compilers (e.g. Tasking for TriCore) the include of the "string_stream" header caused compilation errors: "const variable "etl::left" requires an initializer -- class "etl::private_basic_format_spec::left_spec" has no user-provided default constructor" References: https://en.cppreference.com/w/cpp/language/default_initialization https://cplusplus.github.io/CWG/issues/253.html https://stackoverflow.com/questions/7411515/why-does-c-require-a-user-provided-default-constructor-to-default-construct-a https://stackoverflow.com/questions/24943665/why-is-a-constructor-necessary-in-a-const-member-struct
This commit is contained in:
parent
a98d387a11
commit
7c24f66ecc
@ -172,10 +172,10 @@ namespace etl
|
||||
static ETL_CONSTANT private_basic_format_spec::base_spec hex(16U);
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::left_spec left;
|
||||
static ETL_CONSTANT private_basic_format_spec::left_spec left = private_basic_format_spec::left_spec();
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::right_spec right;
|
||||
static ETL_CONSTANT private_basic_format_spec::right_spec right = private_basic_format_spec::right_spec();
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::boolalpha_spec boolalpha(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user