I'using Clion(2019.2 ).
I found that it would not throw any warning if my function return value not matchs with the return value of function prototype.
For example, following code would not throw any error.
float Add(float value){
float output_value = value + 1;
//return output_value // I don't return any value in this function.
}
However, this may case segment fault randomly and it's very hard to debug.
How can I set Clion to make it throw warning for this case?
If it can not do this, why?
You can enable -Wreturn-type
flag on your compiler to receive proper warnings in such cases.
To enable this flag, add to your CMakeList.txt
file:
set(CMAKE_CXX_FLAGS "-Wreturn-type")