public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr
@ 2021-06-29 17:23 hewillk at gmail dot com
  2021-07-13 17:45 ` [Bug libstdc++/101263] " ppalka at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: hewillk at gmail dot com @ 2021-06-29 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101263
           Summary: non-propagating-cache::emplace-deref missing constexpr
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

Hi, P2328R1 is marked as completed in https://gcc.gnu.org/wiki/LibstdcxxTodo,
but it seems that the constexpr keyword added by R1 has not been added in
libstdc++.

https://godbolt.org/z/d7r6cbTYj

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
@ 2021-07-13 17:45 ` ppalka at gcc dot gnu.org
  2021-09-08  7:42 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-13 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2021-07-13
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
It looks like emplace-deref was made constexpr in R1 of the paper, but we  only
implemented R0.  Fortunately this added constexpr seems to be the only
functional change in R1 vs R0.

We might first need to implement P2231 (for constexpr optional) before this
function can be properly constexpr.

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
  2021-07-13 17:45 ` [Bug libstdc++/101263] " ppalka at gcc dot gnu.org
@ 2021-09-08  7:42 ` rguenth at gcc dot gnu.org
  2021-09-08 10:30 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-08  7:42 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |barry.revzin at gmail dot com

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 102236 has been marked as a duplicate of this bug. ***

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
  2021-07-13 17:45 ` [Bug libstdc++/101263] " ppalka at gcc dot gnu.org
  2021-09-08  7:42 ` rguenth at gcc dot gnu.org
@ 2021-09-08 10:30 ` redi at gcc dot gnu.org
  2021-10-14  8:09 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-08 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #1)
> We might first need to implement P2231 (for constexpr optional) before this
> function can be properly constexpr.

I have a patch for that, but it's not upstream yet.

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-08 10:30 ` redi at gcc dot gnu.org
@ 2021-10-14  8:09 ` redi at gcc dot gnu.org
  2021-10-14 15:22 ` ppalka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-14  8:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #1)
> We might first need to implement P2231 (for constexpr optional) before this
> function can be properly constexpr.

Implemented in r12-4389

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2021-10-14  8:09 ` redi at gcc dot gnu.org
@ 2021-10-14 15:22 ` ppalka at gcc dot gnu.org
  2021-10-14 15:35 ` barry.revzin at gmail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-14 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Patrick Palka from comment #1)
> > We might first need to implement P2231 (for constexpr optional) before this
> > function can be properly constexpr.
> 
> Implemented in r12-4389

Yay, thanks!  I thought this would be enough to straightforwardly make
emplace-deref constexpr, but I ran into an unrelated wrinkle.  During constexpr
evaluation we can't use placement new to initialize the contained value
directly from *__i and instead have to use the equivalent of
construct_at(&value, *__i), but the latter incurs an extra move due to the
temporary materialization of *__i, which is contrary to the effects of
emplace-deref ([range.nonprop.cache]/1.6):

  Calls reset().  Then initializes the contained value as if
direct-non-list-initializing an object of type T with the argument *i.

Am I missing something or is it not possible to perform this direct-init in the
constexpr case?

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2021-10-14 15:22 ` ppalka at gcc dot gnu.org
@ 2021-10-14 15:35 ` barry.revzin at gmail dot com
  2021-10-14 15:43 ` rs2740 at gmail dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: barry.revzin at gmail dot com @ 2021-10-14 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Barry Revzin <barry.revzin at gmail dot com> ---
The "real" answer is allowing constexpr placement new, but that obviously
doesn't help you right now.

But I think the helpful answer is that you can add a constructor to your
storage like storage(init_from_invoke_t, Args&&... args) that initializes the
underlying value from invoke((Args&&)args...), and then construct_at(&storage,
init_from_invoke, [&]() -> decltype(auto) { return *i; }).

Something like that?

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (5 preceding siblings ...)
  2021-10-14 15:35 ` barry.revzin at gmail dot com
@ 2021-10-14 15:43 ` rs2740 at gmail dot com
  2021-10-15 17:27 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rs2740 at gmail dot com @ 2021-10-14 15:43 UTC (permalink / raw)
  To: gcc-bugs

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

TC <rs2740 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rs2740 at gmail dot com

--- Comment #7 from TC <rs2740 at gmail dot com> ---
(In reply to Barry Revzin from comment #6)
> The "real" answer is allowing constexpr placement new, but that obviously
> doesn't help you right now.
> 
> But I think the helpful answer is that you can add a constructor to your
> storage like storage(init_from_invoke_t, Args&&... args) that initializes
> the underlying value from invoke((Args&&)args...), and then
> construct_at(&storage, init_from_invoke, [&]() -> decltype(auto) { return
> *i; }).
> 
> Something like that?

Yes. Something at that level of generality will be needed for the new
optional::transform, so it seems the better approach.

In my proof-of-concept implementation (which didn't have that concern), I used
something tailored to this specific case, along the lines of 

struct __deref_tag {};

template<class _Tp>
struct __cache_wrapper {
    template<class _Iter>
    constexpr __cache_wrapper(__deref_tag, const _Iter& __i)
        : __t(*__i) {}
    _Tp __t;
};

and then stored a __non_propagating_cache<__cache_wrapper<range_value_t<...>>>
__cache, so that emplace-deref(i) is __cache.emplace(__deref_tag{}, i);

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (6 preceding siblings ...)
  2021-10-14 15:43 ` rs2740 at gmail dot com
@ 2021-10-15 17:27 ` cvs-commit at gcc dot gnu.org
  2021-10-15 17:31 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-15 17:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 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:2c564e813c0626802e5bfb066c094933d5e6a774

commit r12-4448-g2c564e813c0626802e5bfb066c094933d5e6a774
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Oct 15 14:49:21 2021 +0100

    libstdc++: Make non-propagating-cache fully constexpr [PR101263]

    libstdc++-v3/ChangeLog:

            PR libstdc++/101263
            * include/std/ranges (__cached): New wrapper struct.
            (__non_propagating_cache): Use __cached for contained value.
            (__non_propagating_cache::_M_emplace_deref): Add constexpr. Use
            std::construct_at instead of placement new.
            * testsuite/std/ranges/adaptors/join.cc: Check constexpr works.

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (7 preceding siblings ...)
  2021-10-15 17:27 ` cvs-commit at gcc dot gnu.org
@ 2021-10-15 17:31 ` redi at gcc dot gnu.org
  2021-11-24 12:22 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-15 17:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.3

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (8 preceding siblings ...)
  2021-10-15 17:31 ` redi at gcc dot gnu.org
@ 2021-11-24 12:22 ` redi at gcc dot gnu.org
  2022-04-21  7:49 ` rguenth at gcc dot gnu.org
  2022-04-21  9:18 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-24 12:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk. It can't be backported without also backporting r12-1068 to fix
PR100368.

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (9 preceding siblings ...)
  2021-11-24 12:22 ` redi at gcc dot gnu.org
@ 2022-04-21  7:49 ` rguenth at gcc dot gnu.org
  2022-04-21  9:18 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

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

* [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
  2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
                   ` (10 preceding siblings ...)
  2022-04-21  7:49 ` rguenth at gcc dot gnu.org
@ 2022-04-21  9:18 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-21  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |12.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't think we're going to do this for gcc-11, so closing.

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

end of thread, other threads:[~2022-04-21  9:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 17:23 [Bug libstdc++/101263] New: non-propagating-cache::emplace-deref missing constexpr hewillk at gmail dot com
2021-07-13 17:45 ` [Bug libstdc++/101263] " ppalka at gcc dot gnu.org
2021-09-08  7:42 ` rguenth at gcc dot gnu.org
2021-09-08 10:30 ` redi at gcc dot gnu.org
2021-10-14  8:09 ` redi at gcc dot gnu.org
2021-10-14 15:22 ` ppalka at gcc dot gnu.org
2021-10-14 15:35 ` barry.revzin at gmail dot com
2021-10-14 15:43 ` rs2740 at gmail dot com
2021-10-15 17:27 ` cvs-commit at gcc dot gnu.org
2021-10-15 17:31 ` redi at gcc dot gnu.org
2021-11-24 12:22 ` redi at gcc dot gnu.org
2022-04-21  7:49 ` rguenth at gcc dot gnu.org
2022-04-21  9:18 ` redi at gcc dot gnu.org

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).