成员模板专用化不使用 clang 进行编译
Member template specialization does not compile with clang
请考虑以下程序:
struct S {
enum E {
e
};
template<E> void f() = delete;
};
template<> void S::f<S::E::e>() {}
int main() {
S s;
s.f<S::E::e>();
}
GCC 5.4.0 编译代码,而 clang 3.8.0 失败:
$ clang++ -std=c++14 main.cpp
main.cpp:10:20: error: redefinition of 'f'
template<> void S::f<S::E::e>() {
^
main.cpp:8:20: note: previous definition is here
template<> void S::f<S::E::e>();
^
main.cpp:14:11: error: no matching member function for call to 'f'
s.f<S::E::e>();
~~^~~~~~~~~~
main.cpp:5:22: note: candidate template ignored: substitution failure [with $0 = S::E::e]
template<E> void f() = delete;
^
2 errors generated.
叮当是正确的,GCC是正确的还是相反?请注意,如果删除了delete
说明符,则 clang 将编译代码。
这
似乎是缺陷报告 已删除函数模板的显式专用化,从这里可以看出,自 3.9.0 以来,这个问题似乎在 clang 中得到了修复。
相关文章:
- 通过自制软件(macOS)安装的clang++:编译错误
- 在使用 Clang 编译 DLL 时指定 DEF 文件
- constexpr 使用 clang 编译 TensorFlow 时出错
- clang编译的程序在std::any_cast期间抛出std::bad_any_cast
- 使用 Android NDK 使用 clang++ 编译C++代码时对"_Unwind_Resume"的未定义引用
- 为什么这段代码无法使用 gcc 4.8.5 编译,而使用 clang 编译正常
- 向 cppFlags 添加"-O0"无法禁用 Android Studio 中的 clang 编译优化
- C++汇编代码分析(使用 clang 编译)
- 为什么以下代码不使用GCC编译,而是用Clang编译罚款
- clang编译错误与static_assert和boost :: hana有关
- clang 编译模板类,并在标题中实现
- 在Windows上使用clang编译CUDA时的重新定义
- 如何在OSX上为clang编译 #include < 实验/任意>
- constexpr 唯一 ID,使用 clang 编译,但不使用 GCC 编译
- 是否可以仅在Windows上使用Clang编译C ++
- 当我用clang编译代码时,GCOV会出现内存错误
- 在MacOS上使用gcc-8而不是clang编译Qt5
- 如何使用 clang 编译特殊的数学函数
- 使用 gcc 编译和使用 clang 编译代码时未定义的引用
- 使用clang编译时regex-segfault,可能存在编译器错误