microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.08k stars 689 forks source link

-Wcomma-in-init should maybe be more aggressive? #5567

Open Keenuts opened 1 year ago

Keenuts commented 1 year ago

Description

Had a bug on a compute shader. Spent quite some time to figure out what's the issue (concurrent read/write to some buffers from multiple threads, etc, so LOTS of places things could go wrong). Turns out the issue is simple:

uint thread_count = 32;
uint width = 4096
uint height = 2048
uint2 size = (width, height) / thread_count

I had forgotten the uint2 in the initializer:

uint2 size = uint2(width, height) / thread_count

Steps to Reproduce

[numthreads(1, 1, 1)]
void main()
{
  uint2 a = (1, 2) / 2;
}

dxc -T cs_6_6 repro.hlsl -Od

Dxc builds with no complaints.

Actual Behavior

Maybe DXC should complain that a constructor list may have been intended? This code does generates the warning:

[numthreads(1, 1, 1)]
void main()
{
  uint2 a = (1, 2);
}

Environment

damyanp commented 2 weeks ago

Note that clang current does emit a warning in these cases.