https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121636
Bug ID: 121636
Summary: inherited templated constructor invocation wrong
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
I have a class that inherits constructors from its base class. And I found gcc
invokes a wrong constructor overloading, with a wrong argument. The issue seems
to exist since gcc 7.x to HEAD, and 6.x runs as expected.
A small code that reproduces the issue is as follow:
https://wandbox.org/permlink/d3W0Mr3WvO0SCDZG
```cpp
#include <stdio.h>
template<typename T>
class base {
public:
template<int N>
base(const T(&arr)[N], int asdf = 468) {
printf("C1: %p, %u, %d\n", arr, N, asdf);
}
base(const T* arr, int n, int asdf = 0) {
printf("C2: %p, %u, %d\n", arr, n, asdf);
}
};
class derived : public base<double> {
public:
using B = base<double>;
using B::B;
};
int main() {
double x[] = {1.0, 2.0, 3.0};
base<double> y(x); // should be "C1: 0x?????????, 3, 468", and it is
correct
derived z(x); // should be "C2: 0x?????????, 3, 0", but it is "C2:
0x?????????, 468, 0"
return 0;
}
```