BIV BIV - 10 months ago 64
C++ Question

force c++ compiler to check returning value

In this example will be called deconstructor of nonexisting object. G++ version 5.3, compiling with -Werror .

vector<vector<float>> segfault()


int main()
return 0;

Answer Source

Both gcc and clang have the option -Wreturn-type.
It is turned on implicitly when using -Wall.
To make ensue it is a compiler error, use -Werror=return-type.