opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.43k stars 5.76k forks source link

missing return values #1650

Closed berak closed 6 years ago

berak commented 6 years ago

originally from here: http://answers.opencv.org/question/192097/problem-with-building-opencv_contrib/

System information (version)
Detailed description

clang9.1 finds several functions with missing return values [-Werror,-Wreturn-type] :

opencv_contrib/modules/face/src/lbph_faces.cpp:312:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]

opencv_contrib/modules/bioinspired/src/retina_ocl.cpp:395:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]

opencv_contrib/modules/bioinspired/src/retina_ocl.cpp:451:65: error: control reaches end of non-void function [-Werror,-Wreturn-type]
const Mat RetinaOCLImpl::getMagnoRAW() const { NOT_IMPLEMENTED; }
                                                               ^
opencv_contrib/modules/bioinspired/src/retina_ocl.cpp:452:65: error: control reaches end of non-void function [-Werror,-Wreturn-type]
const Mat RetinaOCLImpl::getParvoRAW() const { NOT_IMPLEMENTED; }

opencv_contrib/modules/rgbd/src/linemod.cpp:70:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
alalek commented 6 years ago

3.4.1

You should update code from the main repository. CV_Error() is replaced to CV_ErrorNoReturn() implementation recently (for OpenCV modules code only, user apps will require modification in 4.x branch).

Or disable -Werror compiler flag.

CV_Error() always throw exception, so any code after that is a bug.

berak commented 6 years ago

ok, so it's better done by using CV_ErrorNoReturn in those places.

berak commented 6 years ago

ok, let me close this, as it's probably not relevant enough, and the buildbot is not using the ,-Wreturn-type flag, either.