public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
@ 2022-06-13 22:53 enolan at alumni dot cmu.edu
  2022-06-13 23:02 ` [Bug c++/105964] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: enolan at alumni dot cmu.edu @ 2022-06-13 22:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105964
           Summary: [12/13 Regression] Return type deduction fails during
                    NTTP use of function dependent on template parameter
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enolan at alumni dot cmu.edu
  Target Milestone: ---

Created attachment 53132
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53132&action=edit
Proof of concept that reproduces the bug

"It seems that, in a nested template expansion context, for SFINAE purposes,
when filling in default arguments, the compiler is declining to instantiate a
function which has a deduced return type.  Because it declines to instantiate
that function, it can't wind up with a function to implicitly convert to a
pointer-to-function which is a valid NTTP."

However, as can be seen in the attached expanded POC, using an ampersand to
force taking the address of the function when using it as an NTTP causes it to
work again.

Godbolt link: https://godbolt.org/z/j8e6Y5Pq9

Minimal reproduction (godbolt link and attachment contain more context):

struct token {};

struct example {};

template< typename >
struct helper
{
    static constexpr auto c() { return 42; }
};

struct impostor_c
{
    template< typename T, auto= helper< T >::c >
    static example func();
};

example c= impostor_c::func< token >();



> the exact version of gcc

gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC)

> the system type

Fedora release 37 (rawhide)

> the options given when GCC was configured/built

Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-12.1.1-20220507/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-offload-defaulted --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1

> the complete command line that triggers the bug

g++ -std=c++17 poc.cpp

> the compiler output

poc.cpp:55:37: error: no matching function for call to
‘impostor_c::func<token>()’
   55 | example c= impostor_c::func< token >();
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~^~
poc.cpp:28:20: note: candidate: ‘template<class T, auto <anonymous> > static
example impostor_c::func()’
   28 |     static example func();
      |                    ^~~~
poc.cpp:28:20: note:   template argument deduction/substitution failed:

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

* [Bug c++/105964] [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
@ 2022-06-13 23:02 ` pinskia at gcc dot gnu.org
  2022-06-13 23:03 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-13 23:02 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=105779

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well PR 105779 is related but this testcase is not fixed ...

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

* [Bug c++/105964] [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
  2022-06-13 23:02 ` [Bug c++/105964] " pinskia at gcc dot gnu.org
@ 2022-06-13 23:03 ` pinskia at gcc dot gnu.org
  2022-06-20 21:18 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-13 23:03 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

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

* [Bug c++/105964] [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
  2022-06-13 23:02 ` [Bug c++/105964] " pinskia at gcc dot gnu.org
  2022-06-13 23:03 ` pinskia at gcc dot gnu.org
@ 2022-06-20 21:18 ` ppalka at gcc dot gnu.org
  2022-06-22 22:02 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-06-20 21:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |11.3.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |12.1.0, 13.0
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2022-06-20

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r12-1270-ga1b3484a8e6c53.

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

* [Bug c++/105964] [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
                   ` (2 preceding siblings ...)
  2022-06-20 21:18 ` ppalka at gcc dot gnu.org
@ 2022-06-22 22:02 ` jason at gcc dot gnu.org
  2022-06-23  3:23 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2022-06-22 22:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/105964] [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
                   ` (3 preceding siblings ...)
  2022-06-22 22:02 ` jason at gcc dot gnu.org
@ 2022-06-23  3:23 ` cvs-commit at gcc dot gnu.org
  2022-06-23  3:46 ` [Bug c++/105964] [12 " cvs-commit at gcc dot gnu.org
  2022-07-01 14:58 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-23  3:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r13-1210-gd29f61a3291a8c4cff0bd754fa3bb8e9399589bc
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 22 18:19:11 2022 -0400

    c++: dependence of baselink [PR105964]

    helper<token>::c isn't dependent just because we haven't deduced its return
    type yet.  type_dependent_expression_p already knows how to deal with that
    for bare FUNCTION_DECL, but needs to learn to look through a BASELINK.

            PR c++/105964

    gcc/cp/ChangeLog:

            * pt.cc (type_dependent_expression_p): Look through BASELINK.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/nontype-auto21.C: New test.

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

* [Bug c++/105964] [12 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
                   ` (4 preceding siblings ...)
  2022-06-23  3:23 ` cvs-commit at gcc dot gnu.org
@ 2022-06-23  3:46 ` cvs-commit at gcc dot gnu.org
  2022-07-01 14:58 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-23  3:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r12-8507-gc85cea9ca165b0b771d9f913016c9dc8db46b5d7
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 22 18:19:11 2022 -0400

    c++: dependence of baselink [PR105964]

    helper<token>::c isn't dependent just because we haven't deduced its return
    type yet.  type_dependent_expression_p already knows how to deal with that
    for bare FUNCTION_DECL, but needs to learn to look through a BASELINK.

            PR c++/105964

    gcc/cp/ChangeLog:

            * pt.cc (type_dependent_expression_p): Look through BASELINK.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/nontype-auto21.C: New test.

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

* [Bug c++/105964] [12 Regression] Return type deduction fails during NTTP use of function dependent on template parameter
  2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
                   ` (5 preceding siblings ...)
  2022-06-23  3:46 ` [Bug c++/105964] [12 " cvs-commit at gcc dot gnu.org
@ 2022-07-01 14:58 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2022-07-01 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 12.2.

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

end of thread, other threads:[~2022-07-01 14:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 22:53 [Bug c++/105964] New: [12/13 Regression] Return type deduction fails during NTTP use of function dependent on template parameter enolan at alumni dot cmu.edu
2022-06-13 23:02 ` [Bug c++/105964] " pinskia at gcc dot gnu.org
2022-06-13 23:03 ` pinskia at gcc dot gnu.org
2022-06-20 21:18 ` ppalka at gcc dot gnu.org
2022-06-22 22:02 ` jason at gcc dot gnu.org
2022-06-23  3:23 ` cvs-commit at gcc dot gnu.org
2022-06-23  3:46 ` [Bug c++/105964] [12 " cvs-commit at gcc dot gnu.org
2022-07-01 14:58 ` jason 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).