From 73ac393064ddadeced258b45484ea61fb85ec160 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Mon, 2 Dec 2019 14:36:22 -0600 Subject: [PATCH] tweak for GCC, memcpy() -> for-loop I think GCC with optimization is getting confused about what field of this union is active, and then triggers a crazy warning about memcpy()'ing (size_t)-1 bytes. Reading the rules about unions, I think it might be that really only "=" is ever able to switch which union field is active, and our memcpy() here really doesn't technically work to change the active field. Change-Id: Ibe33143161935d5e39b9a2f5d35560e4961056e0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257444 Reviewed-by: Brian Osman Commit-Queue: Mike Klein --- src/gpu/GrWindowRectangles.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gpu/GrWindowRectangles.h b/src/gpu/GrWindowRectangles.h index 1b6bc4dfee..732c99372c 100644 --- a/src/gpu/GrWindowRectangles.h +++ b/src/gpu/GrWindowRectangles.h @@ -70,7 +70,9 @@ inline GrWindowRectangles& GrWindowRectangles::operator=(const GrWindowRectangle SkSafeUnref(this->rec()); fCount = that.fCount; if (fCount <= kNumLocalWindows) { - memcpy(fLocalWindows, that.fLocalWindows, fCount * sizeof(SkIRect)); + for (int i = 0; i < fCount; i++) { + fLocalWindows[i] = that.fLocalWindows[i]; + } } else { fRec = SkRef(that.fRec); }