public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98802] New: class template argument deduce guide leads infinite recursive.
@ 2021-01-23 11:40 netcan1996 at gmail dot com
  2021-01-23 12:11 ` [Bug c++/98802] " netcan1996 at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: netcan1996 at gmail dot com @ 2021-01-23 11:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98802
           Summary: class template argument deduce guide leads infinite
                    recursive.
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: netcan1996 at gmail dot com
  Target Milestone: ---

code here:
https://godbolt.org/z/8W7dK5

#include <iostream>
#include <utility>
using namespace std;

template<typename T, size_t N = 0>
struct List {
    T head;
    List<T, N-1> tail;
};

template<typename T>
struct List<T, 0> {};

template<typename T> List(T) -> List<T, 1>;
template<typename T, size_t N> List(T, List<T, N>) -> List<T, N+1>;

template<size_t N>
using IntList = List<int, N>;

int main(int argc, char** argv) {
    auto list1 = IntList<2>{0, IntList<1>{1, IntList<0>{}}};
    auto list2 = List{0, List{1, List{2}}};

    return 0;
}


error info:

<source>: In instantiation of 'struct List<int, 18446744073709550716>':
<source>:8:18:   recursively required from 'struct List<int,
18446744073709551614>'
<source>:8:18:   required from 'struct List<int, 18446744073709551615>'
<source>:22:41:   required from here
<source>:8:18: fatal error: template instantiation depth exceeds maximum of 900
(use '-ftemplate-depth=' to increase the maximum)
    8 |     List<T, N-1> tail;
      |                  ^~~~
compilation terminated.
Compiler returned: 1

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6)

but it work normal in clang.

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

* [Bug c++/98802] class template argument deduce guide leads infinite recursive.
  2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
@ 2021-01-23 12:11 ` netcan1996 at gmail dot com
  2021-01-25 10:21 ` [Bug c++/98802] [10/11 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328 marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: netcan1996 at gmail dot com @ 2021-01-23 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Net Can <netcan1996 at gmail dot com> ---
g++ -std=c++17 work on but not work on -std=c++2a.

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

* [Bug c++/98802] [10/11 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328
  2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
  2021-01-23 12:11 ` [Bug c++/98802] " netcan1996 at gmail dot com
@ 2021-01-25 10:21 ` marxin at gcc dot gnu.org
  2021-02-04  2:41 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-01-25 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |10.3
   Last reconfirmed|                            |2021-01-25
            Summary|class template argument     |[10/11 Regression] class
                   |deduce guide leads infinite |template argument deduce
                   |recursive.                  |guide leads infinite
                   |                            |recursive since
                   |                            |r10-4719-g9b41ebbcdf9e3328

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r10-4719-g9b41ebbcdf9e3328.

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

* [Bug c++/98802] [10/11 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328
  2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
  2021-01-23 12:11 ` [Bug c++/98802] " netcan1996 at gmail dot com
  2021-01-25 10:21 ` [Bug c++/98802] [10/11 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328 marxin at gcc dot gnu.org
@ 2021-02-04  2:41 ` jason at gcc dot gnu.org
  2021-02-04  5:54 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2021-02-04  2:41 UTC (permalink / raw)
  To: gcc-bugs

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

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] 7+ messages in thread

* [Bug c++/98802] [10/11 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328
  2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
                   ` (2 preceding siblings ...)
  2021-02-04  2:41 ` jason at gcc dot gnu.org
@ 2021-02-04  5:54 ` cvs-commit at gcc dot gnu.org
  2021-02-04  6:46 ` [Bug c++/98802] [10 " cvs-commit at gcc dot gnu.org
  2021-02-04 13:37 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-04  5:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:787f3ebf00d4e1f741ea03b6ddea9cf07a6f94ac

commit r11-7096-g787f3ebf00d4e1f741ea03b6ddea9cf07a6f94ac
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 3 21:56:59 2021 -0500

    c++: No aggregate CTAD with explicit dguide [PR98802]

    In my implementation of P2082R1 I missed this piece: the aggregate
deduction
    candidate is not generated if the class has user-written deduction guides.

    gcc/cp/ChangeLog:

            PR c++/98802
            * pt.c (do_class_deduction): No aggregate guide if any_dguides_p.

    gcc/testsuite/ChangeLog:

            PR c++/98802
            * g++.dg/cpp1z/class-deduction78.C: New test.

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

* [Bug c++/98802] [10 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328
  2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
                   ` (3 preceding siblings ...)
  2021-02-04  5:54 ` cvs-commit at gcc dot gnu.org
@ 2021-02-04  6:46 ` cvs-commit at gcc dot gnu.org
  2021-02-04 13:37 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-04  6:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:96bff67d349b134dbcafc5c565ac3ce3a5cf544b

commit r10-9345-g96bff67d349b134dbcafc5c565ac3ce3a5cf544b
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 3 21:56:59 2021 -0500

    c++: No aggregate CTAD with explicit dguide [PR98802]

    In my implementation of P2082R1 I missed this piece: the aggregate
deduction
    candidate is not generated if the class has user-written deduction guides.

    gcc/cp/ChangeLog:

            PR c++/98802
            * pt.c (deduction_guides_for): Add any_dguides_p parm.
            (do_class_deduction): No aggregate guide if any_dguides_p.

    gcc/testsuite/ChangeLog:

            PR c++/98802
            * g++.dg/cpp1z/class-deduction78.C: New test.

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

* [Bug c++/98802] [10 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328
  2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
                   ` (4 preceding siblings ...)
  2021-02-04  6:46 ` [Bug c++/98802] [10 " cvs-commit at gcc dot gnu.org
@ 2021-02-04 13:37 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2021-02-04 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2021-02-04 13:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23 11:40 [Bug c++/98802] New: class template argument deduce guide leads infinite recursive netcan1996 at gmail dot com
2021-01-23 12:11 ` [Bug c++/98802] " netcan1996 at gmail dot com
2021-01-25 10:21 ` [Bug c++/98802] [10/11 Regression] class template argument deduce guide leads infinite recursive since r10-4719-g9b41ebbcdf9e3328 marxin at gcc dot gnu.org
2021-02-04  2:41 ` jason at gcc dot gnu.org
2021-02-04  5:54 ` cvs-commit at gcc dot gnu.org
2021-02-04  6:46 ` [Bug c++/98802] [10 " cvs-commit at gcc dot gnu.org
2021-02-04 13:37 ` 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).