floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.53k stars 468 forks source link

sokol_gfx: warnings when compiling with mingw-w64 #1027

Closed edubart closed 2 months ago

edubart commented 2 months ago

I am getting the following warnings when compiling with x86_64-w64-mingw32-gcc (GCC) 13.1.0:

/mnt/libs/host/sokol_gfx.h: In function ‘_sg_d3d11_apply_pipeline’:
/mnt/libs/host/sokol_gfx.h:10875:5: warning: ‘_sg_d3d11_OMSetBlendState’ reading 16 bytes from a region of size 4 [-Wstringop-overread]
10875 |     _sg_d3d11_OMSetBlendState(_sg.d3d11.ctx, pip->d3d11.bs, &pip->cmn.blend_color.r, 0xFFFFFFFF);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/libs/host/sokol_gfx.h:10875:5: note: referencing argument 3 of type ‘const FLOAT[4]’ {aka ‘const float[4]’}
/mnt/libs/host/sokol_gfx.h:9258:20: note: in a call to function ‘_sg_d3d11_OMSetBlendState’
 9258 | static inline void _sg_d3d11_OMSetBlendState(ID3D11DeviceContext* self, ID3D11BlendState* pBlendState, const FLOAT BlendFactor[4], UINT SampleMask) {
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/libs/host/sokol_gfx.h: In function ‘_sg_d3d11_begin_pass’:
/mnt/libs/host/sokol_gfx.h:10758:13: warning: ‘_sg_d3d11_ClearRenderTargetView’ reading 16 bytes from a region of size 4 [-Wstringop-overread]
10758 |             _sg_d3d11_ClearRenderTargetView(_sg.d3d11.ctx, rtvs[i], &action->colors[i].clear_value.r);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/libs/host/sokol_gfx.h:10758:13: note: referencing argument 3 of type ‘const FLOAT[4]’ {aka ‘const float[4]’}
/mnt/libs/host/sokol_gfx.h:9498:20: note: in a call to function ‘_sg_d3d11_ClearRenderTargetView’
 9498 | static inline void _sg_d3d11_ClearRenderTargetView(ID3D11DeviceContext* self, ID3D11RenderTargetView* pRenderTargetView, const FLOAT ColorRGBA[4]) {
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not really a critical issue, but changing to (float*)&pip->cmn.blend_color can silence this.

floooh commented 2 months ago

Ah right, I've seen this GCC warning in similar code. Maybe I should setup another CI test which uses the mingw toolchain on Windows.

Do you want to provide a PR? The (float*) cast is a good fix.

edubart commented 2 months ago

Do you want to provide a PR? The (float*) cast is a good fix.

Just created PR #1028 with the fix.

floooh commented 2 months ago

Ok, PR has been merged :)