Workaround for debug symbol error with auto-member function?

It seems that the problem is with debug and auto symbols.

I have an auto function in a class:

#include <cstddef> template <typename T> struct binary_expr { auto operator()(std::size_t i){ return 1; } }; int main(){ binary_expr<double> b; return 0; } 

When I compile with g ++ (4.8.2) and -g, I have this error:

 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. 

With clang ++ (3.4) and -g, I have this:

 clang++ -g -std=c++1y auto.cpp error: debug information for auto is not yet supported 1 error generated. 

If I remove -g or set the type explicitly, it works fine.

Is clang ++ supposedly part of C ++ 14?

Is there a workaround for these restrictions or am I screwed up?

+8
c ++ gcc c ++ 11 clang c ++ 14
source share
2 answers

Even after a while, the only workaround I found is to create a function template, a rather stupid workaround ... Obviously, clang has no problems with automatic functions that are templates. I don't know if this works in all cases, but so far it has worked for me.

 #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; } 
0
source share

Now it works on Clang 3.5 SVN. Live example . It seems that the culprit has been a commit since May 2013, see this post on the Clang mailing list.

PR16091: Error trying to emit debug information for undeduced auto return types

Perhaps we should just suppress this, not the mistakes, but since we have the infrastructure for this, I decided that I would use it - if that is the wrong thing, we should probably remove this infrastructure completely. I guess it was from the early days of debugging support support.

 // RUN: %clang_cc1 -emit-llvm-only -std=c++1y -g %s 2>&1 | FileCheck %s 2 3 struct foo { 4 auto func(); // CHECK: error: debug information for auto is not yet supported 5 }; 6 7 foo f; 

However, I cannot find the commit that deleted this information, there may have been an improvement that now prevents this behavior from starting.

+2
source share

All Articles