public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/113060] std::variant converting constructor/assignment is non-conforming after P2280?
Date: Tue, 20 Feb 2024 01:47:06 +0000	[thread overview]
Message-ID: <bug-113060-4-SaksKTPOwo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113060-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Jiang An <de34 at live dot cn> ---
(In reply to Giuseppe D'Angelo from comment #7)
> Hi,
> 
> > Note that this example adds a mediate function template (test_array_element_initializable) to "reduce" the non-constexpr-ness of std::declval.
> 
> That's very clever, thank you! 
> 
> Is it _supposed_ to work, though? I had imagined (possibly erroneusly) that
> once one places the call to `test_array_element_initializable` using
> `declval` as an argument, it would disqualify the whole thing from being
> usable in constant expressions.
> 
> (It would help to have another compiler that implements P2280, so to do more
> tests...)

I think it's supposed to work. Enclosing std::declval calls don't matter
because only the constantness in the trailing return type would affect overload
resolution.

Ah, we don't even need to call the function template or function pointers -
it's sufficient to only detect the well-formedness of the function type.

The simplest "fix" I found is changing
`void_t<decltype(_Arr<_Ti>{{std::declval<_Tp>()}})>`
to
`void_t<auto (_Tp&& __t) -> decltype(_Arr<_Ti>{{std::forward<_Tp>(__t)}})>`
, which seemingly works (https://godbolt.org/z/8M85zre5P).

  parent reply	other threads:[~2024-02-20  1:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18  9:32 [Bug libstdc++/113060] New: " dangelog at gmail dot com
2023-12-18 11:18 ` [Bug libstdc++/113060] " redi at gcc dot gnu.org
2023-12-18 14:32 ` dangelog at gmail dot com
2024-02-16 14:43 ` redi at gcc dot gnu.org
2024-02-19  8:07 ` de34 at live dot cn
2024-02-19  9:07 ` de34 at live dot cn
2024-02-19  9:11 ` de34 at live dot cn
2024-02-19 23:47 ` dangelog at gmail dot com
2024-02-20  1:47 ` de34 at live dot cn [this message]
2024-02-20 10:09 ` dangelog at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113060-4-SaksKTPOwo@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).