to be complete:
gcc11 complains with:
In function 'unit_vec2',
    inlined from 'attempt_line_merge' at /home/eric/work/wine/dlls/d3dx9_36/mesh.c:5542:5:
/home/eric/work/wine/dlls/d3dx9_36/mesh.c:5511:12: warning: 'lastdir' may be used uninitialized [-Wmaybe-uninitialized]
 5511 |     return D3DXVec2Normalize(D3DXVec2Subtract(dir, pt2, pt1), dir);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/eric/work/wine/include/d3dx9.h:31,
                 from /home/eric/work/wine/dlls/d3dx9_36/d3dx9_private.h:32,
                 from /home/eric/work/wine/dlls/d3dx9_36/mesh.c:31:
/home/eric/work/wine/dlls/d3dx9_36/mesh.c: In function 'attempt_line_merge':
/home/eric/work/wine/include/d3dx9math.h:352:21: note: by argument 2 of type 'const D3DXVECTOR2 *' to 'D3DXVec2Normalize' declared here
  352 | D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv);
      |                     ^~~~~~~~~~~~~~~~~
/home/eric/work/wine/dlls/d3dx9_36/mesh.c:5527:25: note: 'lastdir' declared here
 5527 |     D3DXVECTOR2 curdir, lastdir;
      |                         ^~~~~~~

as D3DXV2Normalize isn't symetrical in its arguments definition (first arg is const ptr as input, while second arg is ptr as output)
so gcc11 complains about passing as first arg (being a const ptr) an uninitialized object (it has no way of knowing that both args are aliased)

A+

On Tue, 28 Sept 2021 at 22:57, Henri Verbeet <hverbeet@gmail.com> wrote:
On Tue, 28 Sept 2021 at 18:50, Eric Pouech <eric.pouech@gmail.com> wrote:
>  static inline D3DXVECTOR2 *unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
>  {
> -    return D3DXVec2Normalize(D3DXVec2Subtract(dir, pt2, pt1), dir);
> +    return D3DXVec2Normalize(dir, D3DXVec2Subtract(dir, pt2, pt1));
>  }
>
That's arguably more readable, but note that this doesn't otherwise
make much of a difference; D3DXVec2Subtract() returns the output
vector, so this effectively does "D3DXVec2Normalize(dir, dir);" either
way.


--
--
Eric Pouech