[Bug c++/94310] New: using constructor inheritance breaks the code
tilin97 at yandex dot ru
gcc-bugzilla@gcc.gnu.org
Tue Mar 24 19:51:42 GMT 2020
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
More information about the Gcc-bugs
mailing list