* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
@ 2023-03-21 23:40 ` redi at gcc dot gnu.org
2023-03-22 2:53 ` rs2740 at gmail dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-21 23:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-03-21
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
2023-03-21 23:40 ` [Bug libstdc++/109242] " redi at gcc dot gnu.org
@ 2023-03-22 2:53 ` rs2740 at gmail dot com
2023-03-22 3:02 ` pkasting at google dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rs2740 at gmail dot com @ 2023-03-22 2:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
TC <rs2740 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rs2740 at gmail dot com
--- Comment #1 from TC <rs2740 at gmail dot com> ---
The missing remove_cv_t is real, but this example is invalid. As the linked
cppreference page notes, you cannot pass a PMD to transform.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
2023-03-21 23:40 ` [Bug libstdc++/109242] " redi at gcc dot gnu.org
2023-03-22 2:53 ` rs2740 at gmail dot com
@ 2023-03-22 3:02 ` pkasting at google dot com
2023-03-29 21:26 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pkasting at google dot com @ 2023-03-22 3:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
--- Comment #2 from Peter Kasting <pkasting at google dot com> ---
(In reply to TC from comment #1)
> The missing remove_cv_t is real, but this example is invalid. As the linked
> cppreference page notes, you cannot pass a PMD to transform.
Ah, true! How about this then: https://godbolt.org/z/TaccPEsY1
#include <optional>
struct S {
int& i() const;
};
void foo() {
std::optional<S>().transform(&S::i);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
` (2 preceding siblings ...)
2023-03-22 3:02 ` pkasting at google dot com
@ 2023-03-29 21:26 ` redi at gcc dot gnu.org
2023-03-29 23:45 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-29 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Peter Kasting from comment #2)
> struct S {
> int& i() const;
> };
>
> void foo() {
> std::optional<S>().transform(&S::i);
The U type is a reference here, which isn't allowed.
This shows the bug:
struct A { };
const A f(int);
std::optional<int> o;
A&& p = *o.transform(f);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
` (3 preceding siblings ...)
2023-03-29 21:26 ` redi at gcc dot gnu.org
@ 2023-03-29 23:45 ` cvs-commit at gcc dot gnu.org
2023-03-29 23:47 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-29 23:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
--- Comment #4 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:ee122a2eeaea2ffec0e32577c7372bd4e2289e11
commit r13-6937-gee122a2eeaea2ffec0e32577c7372bd4e2289e11
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Mar 30 00:42:11 2023 +0100
libstdc++: Fix filename of new test [PR109242]
libstdc++-v3/ChangeLog:
PR libstdc++/109242
* testsuite/20_util/optional/monadic/pr109340.cc: Moved to...
* testsuite/20_util/optional/monadic/pr109242.cc: ...here.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
` (4 preceding siblings ...)
2023-03-29 23:45 ` cvs-commit at gcc dot gnu.org
@ 2023-03-29 23:47 ` redi at gcc dot gnu.org
2023-03-30 8:08 ` cvs-commit at gcc dot gnu.org
2023-03-30 8:09 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-29 23:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.3
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk by commit r13-6934-g31a909712014b75fc6ae2ca5eaa425f218bb5f32
I'll backport to gcc-12 too.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
` (5 preceding siblings ...)
2023-03-29 23:47 ` redi at gcc dot gnu.org
@ 2023-03-30 8:08 ` cvs-commit at gcc dot gnu.org
2023-03-30 8:09 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-30 8:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:82e8d1685a1e5fac4880e987ed9684248378bce2
commit r12-9369-g82e8d1685a1e5fac4880e987ed9684248378bce2
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Mar 29 22:16:55 2023 +0100
libstdc++: Use std::remove_cv_t in std::optional::transform [PR109242]
We need to strip cv-qualifiers from the result of the callable passed to
std::optional::transform.
libstdc++-v3/ChangeLog:
PR libstdc++/109242
* include/std/optional (transform): Use std::remove_cv_t.
* testsuite/20_util/optional/monadic/pr109242.cc: New test.
(cherry picked from commit 31a909712014b75fc6ae2ca5eaa425f218bb5f32)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/109242] C++2b std::optional::transform omits required std::remove_cv_t from return optional type
2023-03-21 23:31 [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type pkasting at google dot com
` (6 preceding siblings ...)
2023-03-30 8:08 ` cvs-commit at gcc dot gnu.org
@ 2023-03-30 8:09 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-30 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 12.3, thanks for the report.
^ permalink raw reply [flat|nested] 9+ messages in thread