public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96474] New: Internal compiler error with template struct inside template struct
@ 2020-08-04 23:35 lhlaurini at hotmail dot com
  2020-08-05 12:38 ` [Bug c++/96474] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: lhlaurini at hotmail dot com @ 2020-08-04 23:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96474
           Summary: Internal compiler error with template struct inside
                    template struct
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lhlaurini at hotmail dot com
  Target Milestone: ---

Tested on Arch Linux (10.1.0) and on the online compiler godbolt.org (10.1.0,
10.2.0 and trunk), all with the same results. The following code (compile with
"g++ test.cpp -std=c++17"):

    template <typename T>
    struct A
    {
        template <typename U = T>
        struct B
        {
            //B() {}
        };
    };

    A<int>::B x;

outputs:

    <source>: In substitution of 'template<class U> B()-> A<int>::B<U> [with U
= int]':
    <source>:11:11:   required from here
    <source>:5:12: internal compiler error: in retrieve_specialization, at
cp/pt.c:1240
        5 |     struct B
          |            ^
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <https://gcc.gnu.org/bugs/> for instructions.


Uncommenting "B() {}", it compiles fine (doesn't link, of course). Bug is not
present on 9.3 (also tested on godbolt.org).

---

Godbolt.org with "x86-64 gcc 9.3":

Target: x86_64-linux-gnu

Configured with: ../gcc-9.3.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran,ada,go,d --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build

Thread model: posix

gcc version 9.3.0 (Compiler-Explorer-Build) 

---

Godbolt.org with "x86-64 gcc 10.2":

Target: x86_64-linux-gnu

Configured with: ../gcc-10.2.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran,ada,go,d --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build

Thread model: posix

Supported LTO compression algorithms: zlib

gcc version 10.2.0 (Compiler-Explorer-Build)

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

* [Bug c++/96474] Internal compiler error with template struct inside template struct
  2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
@ 2020-08-05 12:38 ` mpolacek at gcc dot gnu.org
  2020-08-05 13:55 ` lhlaurini at hotmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-08-05 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-08-05

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The ICE started with r278298.  Before that:

96474.C:11:15: error: class template argument deduction failed:
   11 |     A<int>::B x;
      |               ^
96474.C:11:15: error: no matching function for call to ‘B()’

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

* [Bug c++/96474] Internal compiler error with template struct inside template struct
  2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
  2020-08-05 12:38 ` [Bug c++/96474] " mpolacek at gcc dot gnu.org
@ 2020-08-05 13:55 ` lhlaurini at hotmail dot com
  2021-02-11 22:13 ` soko.slav at yandex dot ru
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: lhlaurini at hotmail dot com @ 2020-08-05 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Luiz Henrique Laurini <lhlaurini at hotmail dot com> ---
(In reply to Marek Polacek from comment #1)
> The ICE started with r278298.  Before that:
> 
> 96474.C:11:15: error: class template argument deduction failed:
>    11 |     A<int>::B x;
>       |               ^
> 96474.C:11:15: error: no matching function for call to ‘B()’

Yes, sorry, forgot to add that error. Compiles fine with Clang though. I don't
see why it shouldn't.

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

* [Bug c++/96474] Internal compiler error with template struct inside template struct
  2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
  2020-08-05 12:38 ` [Bug c++/96474] " mpolacek at gcc dot gnu.org
  2020-08-05 13:55 ` lhlaurini at hotmail dot com
@ 2021-02-11 22:13 ` soko.slav at yandex dot ru
  2021-03-03 20:04 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: soko.slav at yandex dot ru @ 2021-02-11 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

Sokolov Viacheslav <soko.slav at yandex dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |soko.slav at yandex dot ru

--- Comment #3 from Sokolov Viacheslav <soko.slav at yandex dot ru> ---
Looks like the following is the same bug: https://godbolt.org/z/YzEh3Y

template <typename = void>
struct A
{
    template <typename = void>
    struct B
    {
    };
};

A<>::B b;

results in (on trunk)

<source>: In substitution of 'template<class> B()-> A<>::B<
<template-parameter-1-1> > [with <template-parameter-1-1> = void]':
<source>:10:8:   required from here
<source>:5:12: internal compiler error: in retrieve_specialization, at
cp/pt.c:1248
    5 |     struct B
      |            ^
0x1ce8359 internal_error(char const*, ...)
        ???:0
0x6b702d fancy_abort(char const*, int, char const*)
        ???:0
0x91364f tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x9498ff instantiate_template(tree_node*, tree_node*, int)
        ???:0
0x9513f6 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0x6de832 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0x906642 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ???:0
0x7b05d4 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ???:0
0x8de81d c_parse_file()
        ???:0
0xa5c452 c_common_parse_file()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

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

* [Bug c++/96474] Internal compiler error with template struct inside template struct
  2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
                   ` (2 preceding siblings ...)
  2021-02-11 22:13 ` soko.slav at yandex dot ru
@ 2021-03-03 20:04 ` mpolacek at gcc dot gnu.org
  2021-03-03 20:13 ` cvs-commit at gcc dot gnu.org
  2021-03-03 20:14 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-03 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Now fixed by r11-7483.  Let's add the tests.

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

* [Bug c++/96474] Internal compiler error with template struct inside template struct
  2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
                   ` (3 preceding siblings ...)
  2021-03-03 20:04 ` mpolacek at gcc dot gnu.org
@ 2021-03-03 20:13 ` cvs-commit at gcc dot gnu.org
  2021-03-03 20:14 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-03 20:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:49df367b17995c54fabe5bca290eede7dfab05b3

commit r11-7494-g49df367b17995c54fabe5bca290eede7dfab05b3
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Mar 3 15:10:21 2021 -0500

    c++: Add fixed test [PR96474]

    Was happy to find out that my recent dguide fix (r11-7483) fixed
    this test too.  In particular, the

    +  /* Wait until the enclosing scope is non-dependent.  */
    +  if (DECL_CLASS_SCOPE_P (tmpl)
    +      && dependent_type_p (DECL_CONTEXT (tmpl)))
    +    return ptype;

    bit.

    gcc/testsuite/ChangeLog:

            PR c++/96474
            * g++.dg/cpp1z/class-deduction83.C: New test.

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

* [Bug c++/96474] Internal compiler error with template struct inside template struct
  2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
                   ` (4 preceding siblings ...)
  2021-03-03 20:13 ` cvs-commit at gcc dot gnu.org
@ 2021-03-03 20:14 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-03 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-03-03 20:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 23:35 [Bug c++/96474] New: Internal compiler error with template struct inside template struct lhlaurini at hotmail dot com
2020-08-05 12:38 ` [Bug c++/96474] " mpolacek at gcc dot gnu.org
2020-08-05 13:55 ` lhlaurini at hotmail dot com
2021-02-11 22:13 ` soko.slav at yandex dot ru
2021-03-03 20:04 ` mpolacek at gcc dot gnu.org
2021-03-03 20:13 ` cvs-commit at gcc dot gnu.org
2021-03-03 20:14 ` mpolacek 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).