Use of 'auto func(int)' before deduction of 'auto' in C++14

后端 未结 4 413
攒了一身酷
攒了一身酷 2020-12-05 13:35

I have compiled following program in GCC using C++14.

#include 
using namespace std;

auto func(int i);

int main() 
{
    auto         


        
4条回答
  •  攒了一身酷
    2020-12-05 14:37

    Clang has a much better error message for that one:

    main.cpp:8:16: error: function 'func' with deduced return type cannot be used before it is defined
        auto ret = func(5);
                   ^
    

    I guess that's self-explanatory.

提交回复
热议问题