[PATCH 0/1] MR3841: wineps: Fix EMRPOLYDRAW16 printing.
It fixes EMRPOLYDRAW16 printing when -O2 option is used (in GCC 12.3.1). The compiler assumes that apts table has 0 or 1 elements and optimizes the loop out. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55486 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3841
From: Piotr Caban <piotr(a)codeweavers.com> It fixes EMRPOLYDRAW16 printing when -O2 option is used (in GCC 12.3.1). The compiler assumes that apts table has 0 or 1 elements and optimizes the loop out. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55486 --- dlls/wineps.drv/printproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/wineps.drv/printproc.c b/dlls/wineps.drv/printproc.c index b899814f8c1..74f43b6d27c 100644 --- a/dlls/wineps.drv/printproc.c +++ b/dlls/wineps.drv/printproc.c @@ -2738,8 +2738,8 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable, if (!pts) return 0; for (i = 0; i < p->cpts; i++) { - pts[i].x = p->apts[i].x; - pts[i].y = p->apts[i].y; + pts[i].x = ((const POINTS *)p->apts)[i].x; + pts[i].y = ((const POINTS *)p->apts)[i].y; } i = poly_draw(data->ctx, pts, (BYTE *)(p->apts + p->cpts), p->cpts) && MoveToEx(data->ctx->hdc, pts[p->cpts - 1].x, pts[p->cpts - 1].y, NULL); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3841
Isn't this compiler bug going to affect a lot of places in Wine? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3841#note_45486
On Fri Sep 15 09:02:53 2023 +0000, Huw Davies wrote:
Isn't this compiler bug going to affect a lot of places in Wine? I don't think it's a compiler bug. In this case the apts table is not the last field of the struct.
I've looked on all the structures in wingdi.h. There are more structures that use variable sized array that is not last in the structure. All the other places already needed casts and were not affected. Similar code in gdi32 already has an implicit cast. I don't know if any other part of wine is affected but such structures are uncommon - fields after variable sized array can't be accessed in normal way. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3841#note_45492
On Fri Sep 15 09:02:53 2023 +0000, Piotr Caban wrote:
I don't think it's a compiler bug. In this case the apts table is not the last field of the struct. I've looked on all the structures in wingdi.h. There are more structures that use variable sized array that is not last in the structure. All the other places already needed casts and were not affected. Similar code in gdi32 already has an implicit cast. I don't know if any other part of wine is affected but such structures are uncommon - fields after variable sized array can't be accessed in normal way. Ah right sorry, got it.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/3841#note_45493
This merge request was approved by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3841
participants (3)
-
Huw Davies (@huw) -
Piotr Caban -
Piotr Caban (@piotr)