Skip to content

Commit 0d854db

Browse files
committed
build: workaround GCC 7.1.1 compilation issue with sanitize flags
Version: gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3) Flags: -fsanitize=address,undefined
1 parent fdb3d4f commit 0d854db

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

modules/ts/src/cuda_test.cpp

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,20 @@ namespace cvtest
322322

323323
if (m1.size() != m2.size())
324324
{
325-
return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
326-
<< expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
327-
<< expr2 << "\" [" << PrintToString(m2.size()) << "]";
325+
std::stringstream msg;
326+
msg << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
327+
<< expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
328+
<< expr2 << "\" [" << PrintToString(m2.size()) << "]";
329+
return AssertionFailure() << msg.str();
328330
}
329331

330332
if (m1.type() != m2.type())
331333
{
332-
return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
333-
<< expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
334-
<< expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
334+
std::stringstream msg;
335+
msg << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
336+
<< expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
337+
<< expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
338+
return AssertionFailure() << msg.str();
335339
}
336340

337341
Mat diff;
@@ -343,12 +347,14 @@ namespace cvtest
343347

344348
if (maxVal > eps)
345349
{
346-
return AssertionFailure() << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
347-
<< "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
348-
<< ", which exceeds \"" << eps_expr << "\", where \""
349-
<< expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
350-
<< expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
351-
<< eps_expr << "\" evaluates to " << eps;
350+
std::stringstream msg;
351+
msg << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
352+
<< "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
353+
<< ", which exceeds \"" << eps_expr << "\", where \""
354+
<< expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
355+
<< expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
356+
<< eps_expr << "\" evaluates to " << eps;
357+
return AssertionFailure() << msg.str();
352358
}
353359

354360
return AssertionSuccess();
@@ -469,9 +475,11 @@ namespace cvtest
469475
{
470476
if (gold.size() != actual.size())
471477
{
472-
return testing::AssertionFailure() << "KeyPoints size mistmach\n"
473-
<< "\"" << gold_expr << "\" : " << gold.size() << "\n"
474-
<< "\"" << actual_expr << "\" : " << actual.size();
478+
std::stringstream msg;
479+
msg << "KeyPoints size mistmach\n"
480+
<< "\"" << gold_expr << "\" : " << gold.size() << "\n"
481+
<< "\"" << actual_expr << "\" : " << actual.size();
482+
return AssertionFailure() << msg.str();
475483
}
476484

477485
std::sort(actual.begin(), actual.end(), KeyPointLess());
@@ -484,14 +492,16 @@ namespace cvtest
484492

485493
if (!keyPointsEquals(p1, p2))
486494
{
487-
return testing::AssertionFailure() << "KeyPoints differ at " << i << "\n"
488-
<< "\"" << gold_expr << "\" vs \"" << actual_expr << "\" : \n"
489-
<< "pt : " << testing::PrintToString(p1.pt) << " vs " << testing::PrintToString(p2.pt) << "\n"
490-
<< "size : " << p1.size << " vs " << p2.size << "\n"
491-
<< "angle : " << p1.angle << " vs " << p2.angle << "\n"
492-
<< "response : " << p1.response << " vs " << p2.response << "\n"
493-
<< "octave : " << p1.octave << " vs " << p2.octave << "\n"
494-
<< "class_id : " << p1.class_id << " vs " << p2.class_id;
495+
std::stringstream msg;
496+
msg << "KeyPoints differ at " << i << "\n"
497+
<< "\"" << gold_expr << "\" vs \"" << actual_expr << "\" : \n"
498+
<< "pt : " << testing::PrintToString(p1.pt) << " vs " << testing::PrintToString(p2.pt) << "\n"
499+
<< "size : " << p1.size << " vs " << p2.size << "\n"
500+
<< "angle : " << p1.angle << " vs " << p2.angle << "\n"
501+
<< "response : " << p1.response << " vs " << p2.response << "\n"
502+
<< "octave : " << p1.octave << " vs " << p2.octave << "\n"
503+
<< "class_id : " << p1.class_id << " vs " << p2.class_id;
504+
return AssertionFailure() << msg.str();
495505
}
496506
}
497507

0 commit comments

Comments
 (0)