DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

DXC should warn on statically checkable out-of-bounds

Open devshgraphicsprogramming opened this issue 2 years ago • 0 comments

Description I made a struct T with a member of type uint[1], then I index it with a literal cosntant 2000.

I'm fairly sure that even though the StructuredBuffer is indeed an OpTypeRuntimeArray, its only for the struct T (see comments in the repro).

Steps to Reproduce https://godbolt.org/z/frv3neY5x

Actual Behavior Obviously if I were to index using some runtime variable instead of a constant literal, its impossible to bounds-check my indexing.

However a constant literal should be easy to check, but I don't know is its invalid SPIR-V and UB to index past the end or its fine?

In either case compiler should emit warning or error.

Environment

  • DXC version Latest on Godbolt
  • Host Operating System Linux?