public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102863] New: Optional monadic ops should not be constrained
@ 2021-10-20 22:53 rs2740 at gmail dot com
  2021-10-20 23:29 ` [Bug libstdc++/102863] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rs2740 at gmail dot com @ 2021-10-20 22:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102863
           Summary: Optional monadic ops should not be constrained
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

It's important that these are not constrained with invocable; that constraint
can trigger hard errors during overload resolution. For instance:

void f(int&);

int main() {
    std::optional<int> x;
    x.transform([](auto& y) { f(y); return 42; });
}

<source>: In instantiation of 'main()::<lambda(auto:3&)> [with auto:3 = const
int]':
/opt/compiler-explorer/gcc-trunk-20211020/include/c++/12.0.0/type_traits:2565:26:
  required by substitution of 'template<class _Fn, class ... _Args> static
std::__result_of_success<decltype (declval<_Fn>()((declval<_Args>)()...)),
std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn =
main()::<lambda(auto:3&)>; _Args = {const int&}]'
/opt/compiler-explorer/gcc-trunk-20211020/include/c++/12.0.0/type_traits:2576:55:
  required from 'struct std::__result_of_impl<false, false,
main()::<lambda(auto:3&)>, const int&>'
/opt/compiler-explorer/gcc-trunk-20211020/include/c++/12.0.0/type_traits:3038:12:
  recursively required by substitution of 'template<class _Result, class _Ret>
struct std::__is_invocable_impl<_Result, _Ret, true, std::__void_t<typename
_CTp::type> > [with _Result = std::__invoke_result<main()::<lambda(auto:3&)>,
const int&>; _Ret = void]'
/opt/compiler-explorer/gcc-trunk-20211020/include/c++/12.0.0/type_traits:3038:12:
  required from 'struct std::is_invocable<main()::<lambda(auto:3&)>, const
int&>'
/opt/compiler-explorer/gcc-trunk-20211020/include/c++/12.0.0/type_traits:3286:71:
  required from 'constexpr const bool
std::is_invocable_v<main()::<lambda(auto:3&)>, const int&>'
/opt/compiler-explorer/gcc-trunk-20211020/include/c++/12.0.0/concepts:336:25:  
required by substitution of 'template<class _Fn>  requires  invocable<_Fn,
const _Tp&> constexpr auto std::optional<int>::transform(_Fn&&) const & [with
_Fn = int]'
<source>:7:16:   required from here
<source>:7:32: error: binding reference of type 'int&' to 'const int' discards
qualifiers
    7 |     x.transform([](auto& y) { f(y); return 42; });
      |                               ~^~~
<source>:3:8: note:   initializing argument 1 of 'void f(int&)'
    3 | void f(int&);
      |        ^~~~

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

* [Bug libstdc++/102863] Optional monadic ops should not be constrained
  2021-10-20 22:53 [Bug libstdc++/102863] New: Optional monadic ops should not be constrained rs2740 at gmail dot com
@ 2021-10-20 23:29 ` redi at gcc dot gnu.org
  2021-10-21  0:23 ` cvs-commit at gcc dot gnu.org
  2021-10-21  0:24 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-20 23:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Target Milestone|---                         |12.0
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Last reconfirmed|                            |2021-10-20

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh bother, I forgot to remove the constraints from my P0798R6 implementation
(where they were present).

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

* [Bug libstdc++/102863] Optional monadic ops should not be constrained
  2021-10-20 22:53 [Bug libstdc++/102863] New: Optional monadic ops should not be constrained rs2740 at gmail dot com
  2021-10-20 23:29 ` [Bug libstdc++/102863] " redi at gcc dot gnu.org
@ 2021-10-21  0:23 ` cvs-commit at gcc dot gnu.org
  2021-10-21  0:24 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-21  0:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:0fac85a24f40ef6098b756e8e8655205f4bfbf3e

commit r12-4586-g0fac85a24f40ef6098b756e8e8655205f4bfbf3e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Oct 21 01:19:45 2021 +0100

    libstdc++: Remove constraints from std::optional monadic ops [PR102863]

    The constraints on transform and and_then can cause errors when checking
    satisfaction. The constraints that were present in R6 of the paper were
    moved for he final F8 revision, and so should have been included in the
    implementation.

    libstdc++-v3/ChangeLog:

            PR libstdc++/102863
            * include/std/optional (optional::and_then, optional::transform):
            Remove requires-clause.
            * testsuite/20_util/optional/monadic/and_then.cc: Check
            overload resolution doesn't cause errors.
            * testsuite/20_util/optional/monadic/transform.cc: Likewise.

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

* [Bug libstdc++/102863] Optional monadic ops should not be constrained
  2021-10-20 22:53 [Bug libstdc++/102863] New: Optional monadic ops should not be constrained rs2740 at gmail dot com
  2021-10-20 23:29 ` [Bug libstdc++/102863] " redi at gcc dot gnu.org
  2021-10-21  0:23 ` cvs-commit at gcc dot gnu.org
@ 2021-10-21  0:24 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-21  0:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed, thanks.

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

end of thread, other threads:[~2021-10-21  0:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 22:53 [Bug libstdc++/102863] New: Optional monadic ops should not be constrained rs2740 at gmail dot com
2021-10-20 23:29 ` [Bug libstdc++/102863] " redi at gcc dot gnu.org
2021-10-21  0:23 ` cvs-commit at gcc dot gnu.org
2021-10-21  0:24 ` 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).