public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs
@ 2023-04-12  8:27 ro at gcc dot gnu.org
  2023-04-12  8:27 ` [Bug libstdc++/109482] " ro at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ro at gcc dot gnu.org @ 2023-04-12  8:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

            Bug ID: 109482
           Summary: experimental/net/internet/endpoint/cons.cc FAILs
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
  Target Milestone: ---
              Host: *-*-solaris2.11
            Target: *-*-solaris2.11
             Build: *-*-solaris2.11

Created attachment 54839
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54839&action=edit
32-bit i386-pc-solaris2.11 cons-cons.ii

Between 20230329 (b2f327b9be81326c9e59fc6da98074c909ac7408) and 20230330
(a23b33a1bdeff7bc2289d9ebb7cb7b7ec0a605f5), the
experimental/net/internet/endpoint/cons.cc test began to FAIL on Solaris
(11.3 and 11.4, SPARC and x86):

+FAIL: experimental/net/internet/endpoint/cons.cc (test for excess errors)
+UNRESOLVED: experimental/net/internet/endpoint/cons.cc compilation failed to
produce executable

The log shows

Excess errors:
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:78:
error: non-constant condition for static assertion
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:78:
error: accessing 'in_addr::<unnamed union>::S_addr' member instead of
initialized 'in_addr::<unnamed union>::S_un_b' member in constant expression

The full message is

/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:
In function 'int main()':
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:78:
error: non-constant condition for static assertion
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:78:
  in 'constexpr' expansion of 'test_constexpr()'
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:63:
  in 'constexpr' expansion of 'test_default()'
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:15:
  in 'constexpr' expansion of
'std::experimental::net::v1::ip::basic_endpoint<_InternetProtocol>::address()
const [with _InternetProtocol = std::experimental::net::v1::ip::tcp]()'
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/experimental/net/internet/endpoint/cons.cc:78:
error: accessing 'in_addr::<unnamed union>::S_addr' member instead of
initialized 'in_addr::<unnamed union>::S_un_b' member in constant expression

This is no doubt due to

commit e0d77144aaa56ee6e00fd0ba520b0a5c7e052423
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Mar 22 17:00:11 2023 +0000

    libstdc++: Fix constexpr functions in <experimental/internet>

but I don't know what's going on.  I'm attaching the preprocessed testcase.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
@ 2023-04-12  8:27 ` ro at gcc dot gnu.org
  2023-04-12 11:38 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ro at gcc dot gnu.org @ 2023-04-12  8:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
  2023-04-12  8:27 ` [Bug libstdc++/109482] " ro at gcc dot gnu.org
@ 2023-04-12 11:38 ` redi at gcc dot gnu.org
  2023-04-12 12:27 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-12 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-04-12
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I see the problem, but it's a pain.

For Solaris the in_addr struct looks roughly like:

struct in_addr {
  union {
    struct bytes { char b[4]; };
    in_addr_t s_addr;
  };
};

which means that a value-initialized in_addr does not have s_addr as the active
member of the union, and so we can't access it in constexpr contexts.

I think this means that the basic_endpoint default ctor cannot be constexpr
before C++20. Sigh.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
  2023-04-12  8:27 ` [Bug libstdc++/109482] " ro at gcc dot gnu.org
  2023-04-12 11:38 ` redi at gcc dot gnu.org
@ 2023-04-12 12:27 ` cvs-commit at gcc dot gnu.org
  2023-04-12 12:29 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-12 12:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:9f10b4957ca6058d1a801c5e4bfe11bf159da809

commit r13-7149-g9f10b4957ca6058d1a801c5e4bfe11bf159da809
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Apr 12 11:55:24 2023 +0100

    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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-04-12 12:27 ` cvs-commit at gcc dot gnu.org
@ 2023-04-12 12:29 ` redi at gcc dot gnu.org
  2023-04-12 12:47 ` m.cencora at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-12 12:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed, by removing functionality :-(

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-04-12 12:29 ` redi at gcc dot gnu.org
@ 2023-04-12 12:47 ` m.cencora at gmail dot com
  2023-04-12 12:57 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: m.cencora at gmail dot com @ 2023-04-12 12:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

m.cencora at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m.cencora at gmail dot com

--- Comment #4 from m.cencora at gmail dot com ---
Can't you use designated initializer?

https://godbolt.org/z/nWP7avK9x

struct in_addr_t
{
    void * dummy;
};

struct in_addr {
  union {
    struct { char b[4]; };
    in_addr_t s_addr;
  };
};


constexpr bool test()
{
    in_addr a = {.s_addr = {}};
    return a.s_addr.dummy == nullptr;
}

static_assert(test());

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-04-12 12:47 ` m.cencora at gmail dot com
@ 2023-04-12 12:57 ` redi at gcc dot gnu.org
  2023-04-12 12:59 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-12 12:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Not when s_addr is a macro for S_un.S_addr or something like that.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-04-12 12:57 ` redi at gcc dot gnu.org
@ 2023-04-12 12:59 ` redi at gcc dot gnu.org
  2023-04-12 13:17 ` redi at gcc dot gnu.org
  2023-04-12 13:27 ` m.cencora at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-12 12:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I did try it.

It's also not valid in older standards, so would give pedantic warnings with
-Wsystem-headers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-04-12 12:59 ` redi at gcc dot gnu.org
@ 2023-04-12 13:17 ` redi at gcc dot gnu.org
  2023-04-12 13:27 ` m.cencora at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-12 13:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> Not when s_addr is a macro for S_un.S_addr or something like that.

The real definition on Solaris is more like:

struct in_addr {
  union {
    struct { char b[4]; };
    in_addr_t S_addr;
  } S_un;
#define s_addr S_un.S_addr
};

And this gives:

error: expected primary-expression before '.' token
     in_addr a = {.s_addr = {}};
                  ^

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109482] experimental/net/internet/endpoint/cons.cc FAILs
  2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-04-12 13:17 ` redi at gcc dot gnu.org
@ 2023-04-12 13:27 ` m.cencora at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: m.cencora at gmail dot com @ 2023-04-12 13:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109482

--- Comment #8 from m.cencora at gmail dot com ---
Ah, I see that gcc doesn't support nested designated initializer in C++ mode
(compared to C mode, or clang in both C and C++ modes).

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-12 13:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12  8:27 [Bug libstdc++/109482] New: experimental/net/internet/endpoint/cons.cc FAILs ro at gcc dot gnu.org
2023-04-12  8:27 ` [Bug libstdc++/109482] " ro at gcc dot gnu.org
2023-04-12 11:38 ` redi at gcc dot gnu.org
2023-04-12 12:27 ` cvs-commit at gcc dot gnu.org
2023-04-12 12:29 ` redi at gcc dot gnu.org
2023-04-12 12:47 ` m.cencora at gmail dot com
2023-04-12 12:57 ` redi at gcc dot gnu.org
2023-04-12 12:59 ` redi at gcc dot gnu.org
2023-04-12 13:17 ` redi at gcc dot gnu.org
2023-04-12 13:27 ` m.cencora at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).