Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround for debug symbol error with auto member function?

There seems to be an issue with debug symbols and auto.

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 the -g or set the type explicitly, it works perfectly.

Isn't clang++ supposed to be C++14 feature complete ?

Is there a workaround for these limitations or I'm screwed ?

like image 335
Baptiste Wicht Avatar asked Jul 07 '14 18:07

Baptiste Wicht


1 Answers

This now seems to works on Clang 3.5 SVN. Live Example. It seems that the culprit was a commit from May 2013, see this message on the Clang mailing list.

PR16091: Error when attempting to emit debug info for undeduced auto return types

Perhaps we should just suppress this, rather than erroring, but since we have the infrastructure for it I figured I'd use it - if this is determined to be not the right thing we should probably remove that infrastructure entirely. I guess it's lying around from the early days of implementing debug info 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 removed this info, perhaps there was an improvement that now prevents that this behavior is being triggered.

like image 90
TemplateRex Avatar answered Nov 16 '22 01:11

TemplateRex