microsoft / microsoft/DirectXShaderCompiler
DXC should warn on statically checkable out-of-bounds
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Godbolt reproduction linked in the issue and confirm how DXC handles a literal index of 2000 into the uint[1] member of struct T. Determine whether the generated SPIR-V makes this invalid or undefined, then add the appropriate warning or error and tests demonstrating the diagnostic for statically out-of-bounds indexing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100