public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
@ 2022-06-03 21:04 joeloser at fastmail dot com
  2022-06-06 12:39 ` [Bug c++/105842] " ppalka at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: joeloser at fastmail dot com @ 2022-06-03 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105842
           Summary: rejects-valid: static member function overload set
                    constrained by concepts for class template results in
                    ambiguous call
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joeloser at fastmail dot com
  Target Milestone: ---

In the following snippet,

```
#include <concepts>
#include <cstddef>

template<class>
struct S {
  static constexpr auto f(const std::unsigned_integral auto value) ->
std::size_t {
    return {};
  }
  static constexpr auto f(const std::signed_integral auto value) -> std::size_t
{
    return f(static_cast<std::size_t>(value));
  }
};
```

The second `f` overload results in a compilation error:

```
error: call of overloaded ‘f(std::size_t)’ is ambiguous
... list of the two candidates
```

This appears to be a GCC bug, but only if S is a class template (regardless of
whether the template parameter list is a type or a non-type). Note that clang
trunk compiles the code fine as-is. If `S` is a class and not a class template,
then GCC accepts the code.

See it live at https://godbolt.org/z/oddxEWGMv

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
@ 2022-06-06 12:39 ` ppalka at gcc dot gnu.org
  2022-07-01 12:22 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-06-06 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |rejects-valid
                 CC|                            |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2022-06-06
      Known to fail|                            |10.3.0, 11.3.0, 12.1.0,
                   |                            |13.0, 9.4.0

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, doesn't seem to be a regression.

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
  2022-06-06 12:39 ` [Bug c++/105842] " ppalka at gcc dot gnu.org
@ 2022-07-01 12:22 ` ppalka at gcc dot gnu.org
  2022-07-13 18:03 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-01 12:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 106046 has been marked as a duplicate of this bug. ***

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
  2022-06-06 12:39 ` [Bug c++/105842] " ppalka at gcc dot gnu.org
  2022-07-01 12:22 ` ppalka at gcc dot gnu.org
@ 2022-07-13 18:03 ` cvs-commit at gcc dot gnu.org
  2022-07-13 18:05 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-13 18:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:f07778f6f92111aa0abfd0f669b148a0bda537a9

commit r13-1687-gf07778f6f92111aa0abfd0f669b148a0bda537a9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jul 13 14:01:28 2022 -0400

    c++: dependence of constrained memfn from current inst [PR105842]

    Here we incorrectly deem the calls to func1, func2 and tmpl2 as
    ambiguous ahead of time ultimately because we mishandle dependence
    of a constrained member function from the current instantiation.

    In type_dependent_expression_p, we already consider dependence of a
    TEMPLATE_DECL's constraints (via uses_outer_template_parms), but
    neglect to do the same for a FUNCTION_DECL (such as that for func1).

    And in satisfy_declaration_constraints, we give up if _any_ template
    argument is dependent, but for non-dependent member functions from
    the current instantiation (such as func2 and tmpl2), we can and must
    check constraints as long as the innermost arguments aren't dependent.

            PR c++/105842

    gcc/cp/ChangeLog:

            * constraint.cc (satisfy_declaration_constraints): Refine early
            exit test for argument dependence.
            * cp-tree.h (uses_outer_template_parms_in_constraints): Declare.
            * pt.cc (template_class_depth): Handle TI_TEMPLATE being a
            FIELD_DECL.
            (usse_outer_template_parms): Factor out constraint dependence
            test into ...
            (uses_outer_template_parms_in_constraints): ... here.
            (type_dependent_expression_p): Use it for FUNCTION_DECL.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-memtmpl6.C: New test.

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
                   ` (2 preceding siblings ...)
  2022-07-13 18:03 ` cvs-commit at gcc dot gnu.org
@ 2022-07-13 18:05 ` ppalka at gcc dot gnu.org
  2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-13 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.2

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
                   ` (3 preceding siblings ...)
  2022-07-13 18:05 ` ppalka at gcc dot gnu.org
@ 2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
  2022-07-21 16:51 ` ppalka at gcc dot gnu.org
  2022-07-27 21:02 ` joeloser at fastmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-21 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:5d6286903f325a7a85e5ab1d04ba942d33d755bc

commit r12-8605-g5d6286903f325a7a85e5ab1d04ba942d33d755bc
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jul 13 14:01:28 2022 -0400

    c++: dependence of constrained memfn from current inst [PR105842]

    Here we incorrectly deem the calls to func1, func2 and tmpl2 as
    ambiguous ahead of time ultimately because we mishandle dependence
    of a constrained member function from the current instantiation.

    In type_dependent_expression_p, we already consider dependence of a
    TEMPLATE_DECL's constraints (via uses_outer_template_parms), but
    neglect to do the same for a FUNCTION_DECL (such as that for func1).

    And in satisfy_declaration_constraints, we give up if _any_ template
    argument is dependent, but for non-dependent member functions from
    the current instantiation (such as func2 and tmpl2), we can and must
    check constraints as long as the innermost arguments aren't dependent.

            PR c++/105842

    gcc/cp/ChangeLog:

            * constraint.cc (satisfy_declaration_constraints): Refine early
            exit test for argument dependence.
            * cp-tree.h (uses_outer_template_parms_in_constraints): Declare.
            * pt.cc (template_class_depth): Handle TI_TEMPLATE being a
            FIELD_DECL.
            (usse_outer_template_parms): Factor out constraint dependence
            test into ...
            (uses_outer_template_parms_in_constraints): ... here.
            (type_dependent_expression_p): Use it for FUNCTION_DECL.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-memtmpl6.C: New test.

    (cherry picked from commit f07778f6f92111aa0abfd0f669b148a0bda537a9)

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
                   ` (4 preceding siblings ...)
  2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
@ 2022-07-21 16:51 ` ppalka at gcc dot gnu.org
  2022-07-27 21:02 ` joeloser at fastmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-21 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.2/13

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

* [Bug c++/105842] rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
  2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
                   ` (5 preceding siblings ...)
  2022-07-21 16:51 ` ppalka at gcc dot gnu.org
@ 2022-07-27 21:02 ` joeloser at fastmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: joeloser at fastmail dot com @ 2022-07-27 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Joe Loser <joeloser at fastmail dot com> ---
(In reply to Patrick Palka from comment #5)
> Fixed for GCC 12.2/13

Thanks for the fix, Patrick!

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

end of thread, other threads:[~2022-07-27 21:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 21:04 [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call joeloser at fastmail dot com
2022-06-06 12:39 ` [Bug c++/105842] " ppalka at gcc dot gnu.org
2022-07-01 12:22 ` ppalka at gcc dot gnu.org
2022-07-13 18:03 ` cvs-commit at gcc dot gnu.org
2022-07-13 18:05 ` ppalka at gcc dot gnu.org
2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:51 ` ppalka at gcc dot gnu.org
2022-07-27 21:02 ` joeloser at fastmail 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).