4

私の理論では、gcc にはバグがあります。以下は、clang と gcc の両方でコンパイルされます。

using type = const struct {}&;

しかし、右辺値参照に変更すると、clang でコンパイルされますが、gcc ではコンパイルされません。

using type = const struct {}&&;

// main.cpp:8:17: error: expected ';' after struct definition
//  typedef struct {}&& type;
//                  ^
// main.cpp:8:17: error: missing type-name in typedef-declaration
// main.cpp:8:22: error: expected constructor, destructor, or type conversion before ';' token
//  typedef const struct {}&& type;
//                                ^

typedefバージョンでも同じエラーで失敗します:

typedef const struct {}&& type;

これが gcc でコンパイルできないのはなぜですか? これは標準の問題ですか、それともバグですか?

4

1 に答える 1