【发布时间】:2019-05-21 04:37:27
【问题描述】:
Clang 8.0.0 和 GCC 9.1.0 在这是否是有效代码方面似乎存在分歧。
struct Foo {
Foo([[maybe_unused]] int x) {}
};
int main() {}
Clang 不会产生警告(即使使用 -Wall -Wextra -Wpedantic),但 GCC 会产生此错误:
test.cpp:2:7: error: expected unqualified-id before '[' token
2 | Foo([[maybe_unused]] int x) {}
| ^
test.cpp:2:7: error: expected ')' before '[' token
2 | Foo([[maybe_unused]] int x) {}
| ~^
| )
那么哪个编译器有bug?
【问题讨论】:
标签: c++ language-lawyer compiler-bug