Files
opencv-MIRROR/modules/core/test
perry_lin 88f2f459db Merge pull request #29069 from perrylin4:fix/11988-rect-unsigned-intersection
core: fix unsigned Rect intersection for disjoint rectangles (#11988) - #29069

Fixes #11988

## Problem
`Rect_<_Tp>::operator&` / `operator&=` returned a non-empty rectangle when two **unsigned** rectangles do not overlap.

### Example:
```cpp
cv::Rect_<unsigned> r1(0, 0, 1, 1);
cv::Rect_<unsigned> r2(2, 2, 1, 1);
auto inter = r1 & r2;  // was [1 x 1 from (2, 2)], expected empty
```
Root cause: the previous implementation subtracted edge coordinates before checking overlap. For `unsigned _Tp`, expressions like `width - (x_max - x_min)` can underflow when rectangles are disjoint.

### Solution
Add a check for underflow

### Tests
Added regression test `Core_Rect.test_unsigned_overflow in modules/core/test/test_misc.cpp`.
2026-08-30 12:04:25 +03:00
..
2018-02-12 07:09:43 -05:00
2025-12-25 15:45:08 +06:00
2026-01-04 15:12:59 +01:00
2018-02-03 19:39:47 +00:00