Invalid C++ Code Prevents Compilation With Clang (Bug #3191)
Description
The file dpstereo.cpp contains some invalid C++ code and will not compile on newer versions of Clang. Although most compilers will not flag the error, the code is clearly not correct.
The specific problem occurs when the macros
#define CV_IMAX3(a,b,c) ((temp3 = (a) >= (b) ? (a) : (b)),(temp3 >= (c) ? temp3 : (c)))
#define CV_IMIN3(a,b,c) ((temp3 = (a) <= (b) ? (a) : (b)),(temp3 <= (c) ? temp3 : (c)))
are used in expressions like
CV_IMAX3( srcdata1[j-3], srcdata1[j-2], srcdata1[j-1] ) - CV_IMIN3( srcdata1[j-3], srcdata1[j-2], srcdata1[j-1] )
Macros do not have local variables, and CV_IMIN3 and CV_IMAX3 both use the variable temp3. Because the subtraction of primitive types does not establish a sequenced-before relation, the expressions substituted for CV_IMIN3 and CV_IMAX3 can be evaluated in either order. This would allow temp3 to be assigned different values depending on how the compiler evaluated the expression. To prevent this problem, C++ prohibits this "unsequenced" assignment.
Associated revisions
Fix unsequenced assignment (Bug #3191).
History
Updated by Victor Kocheganov over 11 years ago
Hello Marcus,
thank you for reporting the issue!
I'll handle it.
Regards,
Victor Kocheganov
- Category set to legacy, contrib
- Status changed from New to Open
- Pull request set to https://github.com/Itseez/opencv/pull/1228
- Target version set to 2.4.7
- Assignee set to Victor Kocheganov
Updated by Victor Kocheganov over 11 years ago
- Status changed from Open to Done