public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call
@ 2021-07-15 15:38 michael.kenzel at gmail dot com
  2023-12-17 16:24 ` [Bug c++/101463] [11/12/13/14 Regression]Using " ppalka at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: michael.kenzel at gmail dot com @ 2021-07-15 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101463
           Summary: Using a constexpr variable template specialization as
                    default argument for non-type template parameter of
                    reference type leads gcc to reject function call
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael.kenzel at gmail dot com
  Target Milestone: ---

The following code will reproduce the issue:

    extern const int a;

    template <typename T>
    constexpr const int& blub = a;

    template <typename T, const int& b = blub<T>>
    void f() {}

    int main()
    {
        f<void>();              // error: no matching function for call to
'f<void>()'
        f<void, blub<void>>();  // ok
    }

Note: gcc will accept the function call when the exact same template argument
is explicitly specified instead.

godbolt link: https://godbolt.org/z/jd3EGWEfo

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

* [Bug c++/101463] [11/12/13/14 Regression]Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call
  2021-07-15 15:38 [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call michael.kenzel at gmail dot com
@ 2023-12-17 16:24 ` ppalka at gcc dot gnu.org
  2024-03-22 14:09 ` [Bug c++/101463] [11/12/13/14 Regression] Using " law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-12-17 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |6.2.0
            Summary|Using a constexpr variable  |[11/12/13/14
                   |template specialization as  |Regression]Using a
                   |default argument for        |constexpr variable template
                   |non-type template parameter |specialization as default
                   |of reference type leads gcc |argument for non-type
                   |to reject function call     |template parameter of
                   |                            |reference type leads gcc to
                   |                            |reject function call
   Last reconfirmed|                            |2023-12-17
   Target Milestone|---                         |11.5

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
GCC 6.1/6.2 accepts (with -std=c++17), we started ICEing on this testcase after
r7-5370-gb4ba0852099ad2, and then rejecting it after r8-7014-ge8ef9fdfb9fd4b.

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

* [Bug c++/101463] [11/12/13/14 Regression] Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call
  2021-07-15 15:38 [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call michael.kenzel at gmail dot com
  2023-12-17 16:24 ` [Bug c++/101463] [11/12/13/14 Regression]Using " ppalka at gcc dot gnu.org
@ 2024-03-22 14:09 ` law at gcc dot gnu.org
  2024-07-19 13:12 ` [Bug c++/101463] [12/13/14/15 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-22 14:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
           Priority|P3                          |P2

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

* [Bug c++/101463] [12/13/14/15 Regression] Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call
  2021-07-15 15:38 [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call michael.kenzel at gmail dot com
  2023-12-17 16:24 ` [Bug c++/101463] [11/12/13/14 Regression]Using " ppalka at gcc dot gnu.org
  2024-03-22 14:09 ` [Bug c++/101463] [11/12/13/14 Regression] Using " law at gcc dot gnu.org
@ 2024-07-19 13:12 ` rguenth at gcc dot gnu.org
  2024-08-20 12:34 ` cvs-commit at gcc dot gnu.org
  2024-08-20 12:35 ` [Bug c++/101463] [12/13/14 " ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-19 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.5                        |12.5

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11 branch is being closed.

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

* [Bug c++/101463] [12/13/14/15 Regression] Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call
  2021-07-15 15:38 [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call michael.kenzel at gmail dot com
                   ` (2 preceding siblings ...)
  2024-07-19 13:12 ` [Bug c++/101463] [12/13/14/15 " rguenth at gcc dot gnu.org
@ 2024-08-20 12:34 ` cvs-commit at gcc dot gnu.org
  2024-08-20 12:35 ` [Bug c++/101463] [12/13/14 " ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-20 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC 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:5348e3cb9bc99d2ee4d7438b8eca5c92fff5b931

commit r15-3038-g5348e3cb9bc99d2ee4d7438b8eca5c92fff5b931
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Aug 20 08:34:36 2024 -0400

    c++: default targ eligibility refinement [PR101463]

    On Tue, 9 Jan 2024, Jason Merrill wrote:
    > On 1/5/24 15:01, Patrick Palka wrote[1]:
    > > Here during default template argument substitution we wrongly consider
    > > the (substituted) default arguments v and vt<int> as value-dependent[1]
    > > which ultimately leads to deduction failure for the calls.
    > >
    > > The bogus value_dependent_expression_p result aside, I noticed
    > > type_unification_real during default targ substitution keeps track of
    > > whether all previous targs are known and non-dependent, as is the case
    > > for these calls.  And in such cases it should be safe to avoid checking
    > > dependence of the substituted default targ and just assume it's not.
    > > This patch implements this optimization, which lets us accept both
    > > testcases by sidestepping the value_dependent_expression_p issue
    > > altogether.
    >
    > Hmm, maybe instead of substituting and asking if it's dependent, we
should
    > specifically look for undeduced parameters.

    This patch implements this refinement, which incidentally fixes PR101463
    just as well.

    [1]: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/641957.html

            PR c++/101463

    gcc/cp/ChangeLog:

            * pt.cc (type_unification_real): Directly look for undeduced
            parameters in the default argument instead of doing a trial
            substitution.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/nontype6.C: New test.
            * g++.dg/cpp1z/nontype6a.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

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

* [Bug c++/101463] [12/13/14 Regression] Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call
  2021-07-15 15:38 [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call michael.kenzel at gmail dot com
                   ` (3 preceding siblings ...)
  2024-08-20 12:34 ` cvs-commit at gcc dot gnu.org
@ 2024-08-20 12:35 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-08-20 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |15.0
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
            Summary|[12/13/14/15 Regression]    |[12/13/14 Regression] Using
                   |Using a constexpr variable  |a constexpr variable
                   |template specialization as  |template specialization as
                   |default argument for        |default argument for
                   |non-type template parameter |non-type template parameter
                   |of reference type leads gcc |of reference type leads gcc
                   |to reject function call     |to reject function call
             Status|NEW                         |ASSIGNED

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

end of thread, other threads:[~2024-08-20 12:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 15:38 [Bug c++/101463] New: Using a constexpr variable template specialization as default argument for non-type template parameter of reference type leads gcc to reject function call michael.kenzel at gmail dot com
2023-12-17 16:24 ` [Bug c++/101463] [11/12/13/14 Regression]Using " ppalka at gcc dot gnu.org
2024-03-22 14:09 ` [Bug c++/101463] [11/12/13/14 Regression] Using " law at gcc dot gnu.org
2024-07-19 13:12 ` [Bug c++/101463] [12/13/14/15 " rguenth at gcc dot gnu.org
2024-08-20 12:34 ` cvs-commit at gcc dot gnu.org
2024-08-20 12:35 ` [Bug c++/101463] [12/13/14 " ppalka 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).