Skip to content

Commit

Permalink
Merge pull request opencv#11986 from alalek:build_eliminate_gcc8_warn…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
alalek committed Jul 17, 2018
2 parents 7cc84ce + d5951bc commit f3ee07c
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/ittnotify/src/ittnotify/ittnotify_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ ITT_INLINE long __itt_interlocked_increment(volatile long* ptr)
#ifdef SDL_STRNCPY_S
#define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l)
#else
#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l)
#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, b)
#endif /* SDL_STRNCPY_S */

#define __itt_fstrdup(s) strdup(s)
Expand Down
4 changes: 4 additions & 0 deletions 3rdparty/openexr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -W
-Wsuggest-override -Winconsistent-missing-override
-Wimplicit-fallthrough
)
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
endif()

ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
Expand Down
3 changes: 3 additions & 0 deletions 3rdparty/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if(CV_ICC)
-wd265 -wd858 -wd873 -wd2196
)
endif()
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
endif()

# Easier to support different versions of protobufs
function(append_if_exist OUTPUT_LIST)
Expand Down
4 changes: 4 additions & 0 deletions apps/createsamples/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif

using namespace cv;

#ifndef PATH_MAX
Expand Down
7 changes: 7 additions & 0 deletions modules/calib3d/src/calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3162,6 +3162,10 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
Point3f* objPtData = objPtMat.ptr<Point3f>();
Point2f* imgPtData1 = imgPtMat1.ptr<Point2f>();

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
for( i = 0; i < nimages; i++, j += ni )
{
Mat objpt = objectPoints.getMat(i);
Expand All @@ -3179,6 +3183,9 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
memcpy( imgPtData2 + j, imgpt2.ptr(), ni*sizeof(imgPtData2[0]) );
}
}
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
}

static Mat prepareCameraMatrix(Mat& cameraMatrix0, int rtype)
Expand Down
7 changes: 7 additions & 0 deletions modules/calib3d/test/test_cameracalibration_badarg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,14 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest
void run(int /* start_from */ )
{
CvMat zeros;
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset(&zeros, 0, sizeof(zeros));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif

C_Caller caller, bad_caller;
CvMat objectPoints_c, r_vec_c, t_vec_c, A_c, distCoeffs_c, imagePoints_c,
Expand Down
21 changes: 19 additions & 2 deletions modules/core/src/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2916,12 +2916,29 @@ cvInitImageHeader( IplImage * image, CvSize size, int depth,
if( !image )
CV_Error( CV_HeaderIsNull, "null pointer to header" );

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset( image, 0, sizeof( *image ));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
image->nSize = sizeof( *image );

icvGetColorModel( channels, &colorModel, &channelSeq );
strncpy( image->colorModel, colorModel, 4 );
strncpy( image->channelSeq, channelSeq, 4 );
for (int i = 0; i < 4; i++)
{
image->colorModel[i] = colorModel[i];
if (colorModel[i] == 0)
break;
}
for (int i = 0; i < 4; i++)
{
image->channelSeq[i] = channelSeq[i];
if (channelSeq[i] == 0)
break;
}

if( size.width < 0 || size.height < 0 )
CV_Error( CV_BadROISize, "Bad input roi" );
Expand Down
7 changes: 7 additions & 0 deletions modules/imgproc/src/contours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ cvStartFindContours_Impl( void* _img, CvMemStorage* storage,
CV_Error( CV_StsBadSize, "" );

CvContourScanner scanner = (CvContourScanner)cvAlloc( sizeof( *scanner ));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset( scanner, 0, sizeof(*scanner) );
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif

scanner->storage1 = scanner->storage2 = storage;
scanner->img0 = (schar *) img;
Expand Down
9 changes: 9 additions & 0 deletions modules/imgproc/src/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,11 @@ static const int CodeDeltas[8][2] =
#define CV_ADJUST_EDGE_COUNT( count, seq ) \
((count) -= ((count) == (seq)->total && !CV_IS_SEQ_CLOSED(seq)))

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif

CV_IMPL void
cvDrawContours( void* _img, CvSeq* contour,
CvScalar _externalColor, CvScalar _holeColor,
Expand Down Expand Up @@ -2895,4 +2900,8 @@ cvGetTextSize( const char *text, const CvFont *_font, CvSize *_size, int *_base_
*_size = size;
}

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop // "-Wclass-memaccess"
#endif

/* End of file. */
7 changes: 7 additions & 0 deletions modules/imgproc/src/floodfill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,15 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
CvScalar newVal, CvScalar lo_diff, CvScalar up_diff,
CvConnectedComp* comp, int flags, CvArr* maskarr )
{
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
if( comp )
memset( comp, 0, sizeof(*comp) );
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif

cv::Mat img = cv::cvarrToMat(arr), mask = cv::cvarrToMat(maskarr);
int area = cv::floodFill(img, mask, seed_point, newVal,
Expand Down
7 changes: 7 additions & 0 deletions modules/imgproc/test/test_moments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@ void CV_MomentsTest::prepare_to_validation( int /*test_case_idx*/ )
int i, y, x, cols = src.cols;
double xc = 0., yc = 0.;

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset( &m, 0, sizeof(m));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif

int coi = 0;
for( y = 0; y < src.rows; y++ )
Expand Down
9 changes: 9 additions & 0 deletions modules/objdetect/src/haar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
# endif
#endif

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif

/* these settings affect the quality of detection: change with care */
#define CV_ADJUST_FEATURES 1
#define CV_ADJUST_WEIGHTS 0
Expand Down Expand Up @@ -2290,4 +2295,8 @@ CvType haar_type( CV_TYPE_NAME_HAAR, icvIsHaarClassifier,
icvReadHaarClassifier, icvWriteHaarClassifier,
icvCloneHaarClassifier );

#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif

/* End of file. */

0 comments on commit f3ee07c

Please sign in to comment.