Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(string_stream): add missing initializations of const format specifiers #849

Commits on Feb 22, 2024

  1. fix(string_stream): add missing initializations of const format speci…

    …fiers
    
    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
    KnoerleMaTLS committed Feb 22, 2024
    Configuration menu
    Copy the full SHA
    0fc004c View commit details
    Browse the repository at this point in the history