Skip to content

Commit f3ee07c

Browse files
committed
Merge pull request opencv#11986 from alalek:build_eliminate_gcc8_warnings
2 parents 7cc84ce + d5951bc commit f3ee07c

File tree

12 files changed

+84
-3
lines changed

12 files changed

+84
-3
lines changed

3rdparty/ittnotify/src/ittnotify/ittnotify_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ ITT_INLINE long __itt_interlocked_increment(volatile long* ptr)
335335
#ifdef SDL_STRNCPY_S
336336
#define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l)
337337
#else
338-
#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l)
338+
#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, b)
339339
#endif /* SDL_STRNCPY_S */
340340

341341
#define __itt_fstrdup(s) strdup(s)

3rdparty/openexr/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -W
4747
-Wsuggest-override -Winconsistent-missing-override
4848
-Wimplicit-fallthrough
4949
)
50+
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
51+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
52+
endif()
53+
5054
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
5155
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
5256
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008

3rdparty/protobuf/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ if(CV_ICC)
2929
-wd265 -wd858 -wd873 -wd2196
3030
)
3131
endif()
32+
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
33+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
34+
endif()
3235

3336
# Easier to support different versions of protobufs
3437
function(append_if_exist OUTPUT_LIST)

apps/createsamples/utility.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
#include "opencv2/highgui.hpp"
5555
#include "opencv2/calib3d.hpp"
5656

57+
#if defined __GNUC__ && __GNUC__ >= 8
58+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
59+
#endif
60+
5761
using namespace cv;
5862

5963
#ifndef PATH_MAX

modules/calib3d/src/calibration.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,6 +3162,10 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
31623162
Point3f* objPtData = objPtMat.ptr<Point3f>();
31633163
Point2f* imgPtData1 = imgPtMat1.ptr<Point2f>();
31643164

3165+
#if defined __GNUC__ && __GNUC__ >= 8
3166+
#pragma GCC diagnostic push
3167+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
3168+
#endif
31653169
for( i = 0; i < nimages; i++, j += ni )
31663170
{
31673171
Mat objpt = objectPoints.getMat(i);
@@ -3179,6 +3183,9 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
31793183
memcpy( imgPtData2 + j, imgpt2.ptr(), ni*sizeof(imgPtData2[0]) );
31803184
}
31813185
}
3186+
#if defined __GNUC__ && __GNUC__ >= 8
3187+
#pragma GCC diagnostic pop
3188+
#endif
31823189
}
31833190

31843191
static Mat prepareCameraMatrix(Mat& cameraMatrix0, int rtype)

modules/calib3d/test/test_cameracalibration_badarg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,14 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest
489489
void run(int /* start_from */ )
490490
{
491491
CvMat zeros;
492+
#if defined __GNUC__ && __GNUC__ >= 8
493+
#pragma GCC diagnostic push
494+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
495+
#endif
492496
memset(&zeros, 0, sizeof(zeros));
497+
#if defined __GNUC__ && __GNUC__ >= 8
498+
#pragma GCC diagnostic pop
499+
#endif
493500

494501
C_Caller caller, bad_caller;
495502
CvMat objectPoints_c, r_vec_c, t_vec_c, A_c, distCoeffs_c, imagePoints_c,

modules/core/src/array.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,12 +2916,29 @@ cvInitImageHeader( IplImage * image, CvSize size, int depth,
29162916
if( !image )
29172917
CV_Error( CV_HeaderIsNull, "null pointer to header" );
29182918

2919+
#if defined __GNUC__ && __GNUC__ >= 8
2920+
#pragma GCC diagnostic push
2921+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
2922+
#endif
29192923
memset( image, 0, sizeof( *image ));
2924+
#if defined __GNUC__ && __GNUC__ >= 8
2925+
#pragma GCC diagnostic pop
2926+
#endif
29202927
image->nSize = sizeof( *image );
29212928

29222929
icvGetColorModel( channels, &colorModel, &channelSeq );
2923-
strncpy( image->colorModel, colorModel, 4 );
2924-
strncpy( image->channelSeq, channelSeq, 4 );
2930+
for (int i = 0; i < 4; i++)
2931+
{
2932+
image->colorModel[i] = colorModel[i];
2933+
if (colorModel[i] == 0)
2934+
break;
2935+
}
2936+
for (int i = 0; i < 4; i++)
2937+
{
2938+
image->channelSeq[i] = channelSeq[i];
2939+
if (channelSeq[i] == 0)
2940+
break;
2941+
}
29252942

29262943
if( size.width < 0 || size.height < 0 )
29272944
CV_Error( CV_BadROISize, "Bad input roi" );

modules/imgproc/src/contours.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ cvStartFindContours_Impl( void* _img, CvMemStorage* storage,
209209
CV_Error( CV_StsBadSize, "" );
210210

211211
CvContourScanner scanner = (CvContourScanner)cvAlloc( sizeof( *scanner ));
212+
#if defined __GNUC__ && __GNUC__ >= 8
213+
#pragma GCC diagnostic push
214+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
215+
#endif
212216
memset( scanner, 0, sizeof(*scanner) );
217+
#if defined __GNUC__ && __GNUC__ >= 8
218+
#pragma GCC diagnostic pop
219+
#endif
213220

214221
scanner->storage1 = scanner->storage2 = storage;
215222
scanner->img0 = (schar *) img;

modules/imgproc/src/drawing.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,11 @@ static const int CodeDeltas[8][2] =
25642564
#define CV_ADJUST_EDGE_COUNT( count, seq ) \
25652565
((count) -= ((count) == (seq)->total && !CV_IS_SEQ_CLOSED(seq)))
25662566

2567+
#if defined __GNUC__ && __GNUC__ >= 8
2568+
#pragma GCC diagnostic push
2569+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
2570+
#endif
2571+
25672572
CV_IMPL void
25682573
cvDrawContours( void* _img, CvSeq* contour,
25692574
CvScalar _externalColor, CvScalar _holeColor,
@@ -2895,4 +2900,8 @@ cvGetTextSize( const char *text, const CvFont *_font, CvSize *_size, int *_base_
28952900
*_size = size;
28962901
}
28972902

2903+
#if defined __GNUC__ && __GNUC__ >= 8
2904+
#pragma GCC diagnostic pop // "-Wclass-memaccess"
2905+
#endif
2906+
28982907
/* End of file. */

modules/imgproc/src/floodfill.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,15 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
642642
CvScalar newVal, CvScalar lo_diff, CvScalar up_diff,
643643
CvConnectedComp* comp, int flags, CvArr* maskarr )
644644
{
645+
#if defined __GNUC__ && __GNUC__ >= 8
646+
#pragma GCC diagnostic push
647+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
648+
#endif
645649
if( comp )
646650
memset( comp, 0, sizeof(*comp) );
651+
#if defined __GNUC__ && __GNUC__ >= 8
652+
#pragma GCC diagnostic pop
653+
#endif
647654

648655
cv::Mat img = cv::cvarrToMat(arr), mask = cv::cvarrToMat(maskarr);
649656
int area = cv::floodFill(img, mask, seed_point, newVal,

modules/imgproc/test/test_moments.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,14 @@ void CV_MomentsTest::prepare_to_validation( int /*test_case_idx*/ )
186186
int i, y, x, cols = src.cols;
187187
double xc = 0., yc = 0.;
188188

189+
#if defined __GNUC__ && __GNUC__ >= 8
190+
#pragma GCC diagnostic push
191+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
192+
#endif
189193
memset( &m, 0, sizeof(m));
194+
#if defined __GNUC__ && __GNUC__ >= 8
195+
#pragma GCC diagnostic pop
196+
#endif
190197

191198
int coi = 0;
192199
for( y = 0; y < src.rows; y++ )

modules/objdetect/src/haar.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
# endif
6868
#endif
6969

70+
#if defined __GNUC__ && __GNUC__ >= 8
71+
#pragma GCC diagnostic push
72+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
73+
#endif
74+
7075
/* these settings affect the quality of detection: change with care */
7176
#define CV_ADJUST_FEATURES 1
7277
#define CV_ADJUST_WEIGHTS 0
@@ -2290,4 +2295,8 @@ CvType haar_type( CV_TYPE_NAME_HAAR, icvIsHaarClassifier,
22902295
icvReadHaarClassifier, icvWriteHaarClassifier,
22912296
icvCloneHaarClassifier );
22922297

2298+
#if defined __GNUC__ && __GNUC__ >= 8
2299+
#pragma GCC diagnostic pop
2300+
#endif
2301+
22932302
/* End of file. */

0 commit comments

Comments
 (0)