etl
7c24f66e - fix(string_stream): add missing initializations of const format specifiers (#849)

Commit
263 days ago
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
Author
Parents
Loading