public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tilin97 at yandex dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94310] New: using constructor inheritance breaks the code
Date: Tue, 24 Mar 2020 19:51:42 +0000	[thread overview]
Message-ID: <bug-94310-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2020-03-24 19:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 19:51 tilin97 at yandex dot ru [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94310-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).