WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

<complex>: Structured binding for complex is accidentally enabled before C++26, in a C++26-incompatible way #5913

@frederick-vs-ja

Description

@frederick-vs-ja

When attempting to implement WG21-P2819R2 "Add The Tuple Protocol To complex", I found that the following thing is accepted by MSVC STL (Godbolt link).

#include <complex>

int main() {
    auto [xy] = std::complex<double>{};
}

Currently, MSVC STL's complex satisfies the conditions in [dcl.struct.bind]/8 - it has only one data member of type value_type[2] which is public and inherited from its base class.

Since C++26, the aforementioned example will certainly stop working. Do we want to reject it in old modes by making something private? Given complex doesn't seem able to be passed or returned in registers, perhaps such change is ABI-compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions