Bap*_*cht 8 c++ gcc clang c++11 c++14
调试符号和自动似乎存在问题.
我在课堂上有一个自动功能:
#include <cstddef>
template <typename T>
struct binary_expr {
auto operator()(std::size_t i){
return 1;
}
};
int main(){
binary_expr<double> b;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我用G ++(4.8.2)和-g编译时,我有这个错误:
g++ -g -std=c++1y auto.cpp
auto.cpp: In instantiation of ‘struct binary_expr<double>’:
auto.cpp:11:25: required from here
auto.cpp:4:8: internal compiler error: in gen_type_die_with_usage, at dwarf2out.c:19484
struct binary_expr {
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.
Run Code Online (Sandbox Code Playgroud)
使用clang ++(3.4)和-g,我有:
clang++ -g -std=c++1y auto.cpp
error: debug information for auto is not yet supported
1 error generated.
Run Code Online (Sandbox Code Playgroud)
如果我删除-g或明确设置类型,它可以完美地工作.
是不是clang ++应该是C++ 14功能完整?
是否存在针对这些限制的解决方法或者我搞砸了?
即使过了一段时间,我发现的唯一解决方法就是制作函数模板,这是非常愚蠢的解决方法......显然,clang 对于作为模板的自动函数没有问题。我不知道这是否适用于所有情况,但到目前为止它对我有用。
#include <cstddef>
template <typename T>
struct binary_expr {
template<typename E = void>
auto operator()(std::size_t i){
return 1;
}
};
int main(){
binary_expr<double> b;
return 0;
}
Run Code Online (Sandbox Code Playgroud)