How can I declare a function in a class that uses return type inference?
This is normal:
auto foo() { return 5; }
But this does not work:
class Test { auto foo(); }; auto Test::foo() { return 5; }
internal compiler error: in gen_type_die_with_usage, on dwarf2out.c: 19486
I do not know if it has anything to do with it, but I am using QtCreator 3.3.
EDIT : I am using Qt 5.4 and QtCreator 3.3. I added the CONFIG += c++14 file to the project file. By default, I use GCC 4.8.2, and I think thatβs why I get the error (I need 4.9 ). However, when I use Clang 3.5 ( 3.4 is required), it says
error: "auto" return without return type; inferred return types are an extension of C ++ 1y
EDIT2 . This seems to be a bug with Qt, not GCC. Outside of Qt, I can write class functions with type inferences of the return type, and it compiles and works fine with GCC 4.8.2 and Clang 3.5.0
source share