public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94310] New: using constructor inheritance breaks the code
@ 2020-03-24 19:51 tilin97 at yandex dot ru
  2020-04-18 17:20 ` [Bug c++/94310] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tilin97 at yandex dot ru @ 2020-03-24 19:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94310
           Summary: using constructor inheritance breaks the code
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tilin97 at yandex dot ru
  Target Milestone: ---

The following code is compiled without errors

template<typename>
struct B {
};

template<typename... Types>
struct A : public B<Types>... {
    using B<Types>::operator=...;
    using B<Types>::B...;
};

int main() {}

But when you change the order of using declarations compilation fails (the same
error occurs in all versions of gcc on godbolt.org)

template<typename>
struct B {
};

template<typename... Types>
struct A : public B<Types>... {
    using B<Types>::B...;                <---
    using B<Types>::operator=...;        <---
};

int main() {}

gcc -v -std=c++17 -Wall -Wextra main.cpp
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.2.1-17ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--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-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 --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,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.2.1 20191102 (Ubuntu 9.2.1-17ubuntu1~18.04.1) 
COLLECT_GCC_OPTIONS='-v' '-std=c++17' '-Wall' '-Wextra' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -imultiarch x86_64-linux-gnu
-D_GNU_SOURCE main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=x86-64
-auxbase main -Wall -Wextra -std=c++17 -version -fasynchronous-unwind-tables
-fstack-protector-strong -Wformat-security -o /tmp/ccVHNdqy.s
GNU C++17 (Ubuntu 9.2.1-17ubuntu1~18.04.1) version 9.2.1 20191102
(x86_64-linux-gnu)
        compiled by GNU C version 9.2.1 20191102, GMP version 6.1.2, MPFR
version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/9
 /usr/include/x86_64-linux-gnu/c++/9
 /usr/include/c++/9/backward
 /usr/lib/gcc/x86_64-linux-gnu/9/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/9/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++17 (Ubuntu 9.2.1-17ubuntu1~18.04.1) version 9.2.1 20191102
(x86_64-linux-gnu)
        compiled by GNU C version 9.2.1 20191102, GMP version 6.1.2, MPFR
version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 33caeb1da5df6f896d4e495951c13eae
main.cpp:8:11: error: expected nested-name-specifier before ‘B’
    8 |     using B<Types>::operator=...;
      |           ^


-----------------------------

The following code is also compiled with an error if there is no comment

template<typename T>
struct B {
        void foo() {}
};

template<typename... Types>
struct A : public B<Types>... {
        // using B<Types>::B...;      <---

        void bar() {
                (B<Types>::foo() , ...);
        }
};

int main() {}

gcc -std=c++17 -Wall -Wextra b.cpp
b.cpp: In member function ‘void A<Types>::bar()’:
b.cpp:11:11: error: expected primary-expression before ‘>’ token
   11 |   (B<Types>::foo() , ...);
      |           ^
b.cpp:11:14: error: ‘::foo’ has not been declared
   11 |   (B<Types>::foo() , ...);
      |              ^~~
b.cpp:11:11: error: binary expression in operand of fold-expression
   11 |   (B<Types>::foo() , ...);
      |    ~~~~~~~^~~~~~~~
b.cpp:11:11: error: operand of fold expression has no unexpanded parameter
packs

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

* [Bug c++/94310] using constructor inheritance breaks the code
  2020-03-24 19:51 [Bug c++/94310] New: using constructor inheritance breaks the code tilin97 at yandex dot ru
@ 2020-04-18 17:20 ` mpolacek at gcc dot gnu.org
  2020-04-19  4:44 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-18 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Doesn't seem like a regression.

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

* [Bug c++/94310] using constructor inheritance breaks the code
  2020-03-24 19:51 [Bug c++/94310] New: using constructor inheritance breaks the code tilin97 at yandex dot ru
  2020-04-18 17:20 ` [Bug c++/94310] " mpolacek at gcc dot gnu.org
@ 2020-04-19  4:44 ` mpolacek at gcc dot gnu.org
  2020-04-19 15:09 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-19  4:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The difference stems from the fact that in this test:

template<typename>
struct B { };

template<typename... Types>
struct A : public B<Types>... {
    using B<Types>::B...; // #1
    using B<Types>::operator=...; // #2
};

int main() {}

when parsing B<Types> in #2 cp_parser_lookup_name finds #1, which is a
dependent USING_DECL.  strip_using_decl doesn't do anything with such a
USING_DECL, so we think that we haven't found a template name.

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

* [Bug c++/94310] using constructor inheritance breaks the code
  2020-03-24 19:51 [Bug c++/94310] New: using constructor inheritance breaks the code tilin97 at yandex dot ru
  2020-04-18 17:20 ` [Bug c++/94310] " mpolacek at gcc dot gnu.org
  2020-04-19  4:44 ` mpolacek at gcc dot gnu.org
@ 2020-04-19 15:09 ` mpolacek at gcc dot gnu.org
  2021-10-18 18:38 ` ppalka at gcc dot gnu.org
  2021-12-09  5:52 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-19 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Potential fix:

--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16982,6 +16982,15 @@ cp_parser_template_name (cp_parser* parser,

   decl = strip_using_decl (decl);

+  if (TREE_CODE (decl) == USING_DECL
+      && TREE_CODE (USING_DECL_SCOPE (decl)) == TYPE_PACK_EXPANSION)
+    {
+      tree t = PACK_EXPANSION_PATTERN (USING_DECL_SCOPE (decl));
+      t = get_template_info (t);
+      if (t)
+   decl = TI_TEMPLATE (t);
+    }
+
   /* If DECL is a template, then the name was a template-name.  */
   if (TREE_CODE (decl) == TEMPLATE_DECL)
     {

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

* [Bug c++/94310] using constructor inheritance breaks the code
  2020-03-24 19:51 [Bug c++/94310] New: using constructor inheritance breaks the code tilin97 at yandex dot ru
                   ` (2 preceding siblings ...)
  2020-04-19 15:09 ` mpolacek at gcc dot gnu.org
@ 2021-10-18 18:38 ` ppalka at gcc dot gnu.org
  2021-12-09  5:52 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-18 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
                 CC|                            |ppalka at gcc dot gnu.org
   Target Milestone|---                         |11.0

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This looks fixed in GCC 11/12, ever since r11-6942

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

* [Bug c++/94310] using constructor inheritance breaks the code
  2020-03-24 19:51 [Bug c++/94310] New: using constructor inheritance breaks the code tilin97 at yandex dot ru
                   ` (3 preceding siblings ...)
  2021-10-18 18:38 ` ppalka at gcc dot gnu.org
@ 2021-12-09  5:52 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09  5:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |DUPLICATE

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 80417.

*** This bug has been marked as a duplicate of bug 80417 ***

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

end of thread, other threads:[~2021-12-09  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 19:51 [Bug c++/94310] New: using constructor inheritance breaks the code tilin97 at yandex dot ru
2020-04-18 17:20 ` [Bug c++/94310] " mpolacek at gcc dot gnu.org
2020-04-19  4:44 ` mpolacek at gcc dot gnu.org
2020-04-19 15:09 ` mpolacek at gcc dot gnu.org
2021-10-18 18:38 ` ppalka at gcc dot gnu.org
2021-12-09  5:52 ` pinskia 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).