microsoft / microsoft/DirectXShaderCompiler

No bounds check on matrix access in type constructor

Open
#6,895 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug incorrect-code
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
I noticed that there seems to be no bounds check on matrix access when it is wrapped in a type constructor.

Steps to Reproduce
https://shader-playground.timjones.io/0aaa9f3162e186ce4ce9da1926b93a40

float4x4 M;
float4 PSMain() : SV_TARGET
{
return float4(M[8]);
}

Actual Behavior
I was expecting a compilation error on the out of bounds access M[8]. If I remove the redundant float4() type constructor, it yields a compilation error as expected.

Environment
Shader playground. Trunk (2024-04-29).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shader-playground example with the HLSL expression M[8] wrapped in float4(), then compare it with the direct M[8] form. Trace the compiler handling of matrix indexing and type-constructor expressions, and identify the relevant regression-test location. Done means the wrapped out-of-bounds access produces the expected compilation error without changing the valid case.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.