Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HLSL] Clang is missing a warning for implicit truncation of vector types in HLSL #134761

Open
bogner opened this issue Apr 8, 2025 · 1 comment
Labels
HLSL HLSL Language Support

Comments

@bogner
Copy link
Contributor

bogner commented Apr 8, 2025

HLSL allows implicit truncation of vector types, but DXC warns about it. Clang needs to learn this warning.

// RUN: %dxc -T cs_6_5 -verify
StructuredBuffer<int4> In : register(t0);
RWStructuredBuffer<int> Out : register(u0);

[numthreads(4,2,1)]
void main(uint GI : SV_GroupIndex) {
  Out[GI] = In[GI]; // expected-warning{{implicit truncation of vector type}}
}

See https://hlsl.godbolt.org/z/o7j6d7r88

@bogner bogner added the HLSL HLSL Language Support label Apr 8, 2025
@bogner bogner moved this to Planning in HLSL Support Apr 8, 2025
@damyanp
Copy link
Contributor

damyanp commented Apr 8, 2025

Isn't this just because -Wconversion isn't enabled by default? With -Wconversion:

<source>:7:13: warning: implicit conversion turns vector to scalar: 'vector<int, 4>' (vector of 4 'int' values) to 'int' [-Wconversion]
    7 |   Out[GI] = In[GI];
      |           ~ ^~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HLSL HLSL Language Support
Projects
Status: Planning
Development

No branches or pull requests

2 participants