g++-10中如何结合base-class显式构造函数和指定初始化?

How to combine base-class explicit constructor and designated initialization in g++-10?

我有一个简单的例子:

struct A {
    explicit A(int a) : a(a) {}
 protected:
    int a;
};
struct B : public A { int b = 0, c = 0; };

// Attempts to get the code compiled:
B b1 { A(1),   .c = 2 };  // fine with clang-11
B b2 { A{1},   .c = 2 };
B b3 { .A{1},  .c = 2 };
B b4 { {1},    .c = 2 };
B b5 { .a = 1, .c = 2 };

第一个示例在 g++10 -std=c++20 上失败,错误为:

error: either all initializer clauses should be designated or none of them should be

虽然在 clang++-11 上没问题。

是否有任何正确的句法方法可以实现以下目标:

或者在这种特殊情况下,Clang 编译器是否不符合 C++20 标准?我看到 问题,它的答案表明是这样的:mixing designated initializers with non-designated initializers, which is not allowed.

你不能。目前,还没有办法在还需要初始化基class 的braced-init-list 中使用指定的初始化器。 There's a proposal for it,但显然目前C++中没有