Issue |
141144
|
Summary |
[HLSL] Investigate how to handle erroring/warning of out-of-bounds vector access
|
Labels |
new issue
|
Assignees |
|
Reporter |
Icohedron
|
Currently, Clang does not emit a warning or error upon encountering an out-of-bounds vector index.
This does not match DXC behavior, which emits an error
https://godbolt.org/z/3Mfjvn5Ex
```hlsl
export float test(float4 v4) {
return v4[5];
}
/* DXC output
<source>:2:15: error: vector element index '5' is out of bounds
return v4[5];
^
*/
```
https://godbolt.org/z/zGc9ox5d1
```hlsl
export float2 test(float4 v4) {
float2 res = { v4[4], v4[5] };
return res;
}
/* DXC output
error: validation errors
<source>:3:5: error: Instructions should not read uninitialized value.
note: at 'ret <2 x float> undef' in block '#0' of function '?test@@YA?AV?$vector@M$01@@V?$vector@M$03@@@Z'.
Validation failed.
*/
```
Should we match DXC behavior and error upon encountering an out-of-bounds vector index? Or should we simply create a warning?
Should we error/warn only for HLSL, or for all languages? Perhaps error for HLSL but warn for all other languages?
An error for out-of-bounds vector indexing has attempted to be implemented before (#128952), but it broke builds (see https://github.com/llvm/llvm-project/pull/128952#issuecomment-2717565787).
We should also consider what @efriedma-quic mentioned (https://github.com/llvm/llvm-project/pull/128952#discussion_r2004302122) about generally not wanting to have differing semantic rules based on whether or not a value is constant.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs