libstdc++: Initialize all members of basic_endpoint union [PR109482]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 12 Apr 2023 10:55:24 +0000 (11:55 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 12 Apr 2023 12:15:12 +0000 (13:15 +0100)
commit9f10b4957ca6058d1a801c5e4bfe11bf159da809
treef629d59ee1176896a45a7f407ab09445c98677e9
parent88ed90187ffff3870a9514007672f13476ff96a7
libstdc++: Initialize all members of basic_endpoint union [PR109482]

On Solaris the in_addr struct contains a union and value-initializing it
does not make the s_addr member active. This means we can't access that
member later during constant evaluation.

Make the constructors explicitly set every member that we might want to
read later in constexpr member functions. This means even the default
constructor can only be constexpr for C++20, because we can't change the
active member of a union in older standards.

libstdc++-v3/ChangeLog:

PR libstdc++/109482
* include/experimental/internet (basic_endpoint::basic_endpoint()):
Ensure that the required union members are active. Only define
as constexpr for C++20 and later.
(basic_endpoint::basic_endpoint(const protocol_type&, port_type)):
Likewise.
* testsuite/experimental/net/internet/endpoint/cons.cc: Only
check constexpr default constructor for C++20 and later.
* testsuite/experimental/net/internet/endpoint/extensible.cc:
Likewise.
libstdc++-v3/include/experimental/internet
libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc
libstdc++-v3/testsuite/experimental/net/internet/endpoint/extensible.cc