나는 ++ 4.9.0를 g을 사용하여 다음과 같은 간단한 코드를 컴파일하기 위해 노력하고있어 :가상베이스의 생성자를 상속받을 수없는 이유는 무엇입니까?
struct A {
explicit A(int x) { }
};
struct B : public virtual A {
using A::A;
};
int main(int argc, char** argv) {
B b(0);
return 0;
}
그러나 나는 다음과 같은 오류 얻을 :
$ g++ -std=c++11 main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:10:10: error: use of deleted function ‘B::B(int)’
B b(0);
^
main.cpp:6:14: note: ‘B::B(int)’ is implicitly deleted because the default definition would be ill-formed:
using A::A;
^
main.cpp:6:14: error: no matching function for call to ‘A::A()’
main.cpp:6:14: note: candidates are:
main.cpp:2:14: note: A::A(int)
explicit A(int x) { }
^
main.cpp:2:14: note: candidate expects 1 argument, 0 provided
main.cpp:1:8: note: constexpr A::A(const A&)
struct A {
^
main.cpp:1:8: note: candidate expects 1 argument, 0 provided
main.cpp:1:8: note: constexpr A::A(A&&)
main.cpp:1:8: note: candidate expects 1 argument, 0 provided
내가 뭔가 잘못하고 오전? 컴파일러 버그입니까?
hm, [clang 컴파일] (http://coliru.stacked-crooked.com/a/24e4b21aeab3cf4d)이 아닌 gcc – quantdev
이것은 GCC 버그 [58751] (https://gcc.gnu.org/bugzilla)입니다. /show_bug.cgi?id=58751). –
SO 관련이 있습니다 (실제로 gcc 파일 보고서의 소스입니다) : http://stackoverflow.com/questions/19399644/inheriting-constructors-and-virtual-base-classes – quantdev