microsoft / microsoft/DirectXShaderCompiler

Can construct-cast an array type to non-array without compiler complaining (DXIL Crash)

Open
#5,632 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug crash diagnostic dxil
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description

I have a member in a struct of type uint _pad[1]

if turns out its possible for me to do

float(obj._pad)

without the compiler warning or complaining, and it will even emit on the OpLoad-ed access chain

         %25 = OpCompositeExtract %uint %24 0

so this behaves as-if I did float(obj._pad[0]) ?

Is this intended behaviour?

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

Actual Behavior

No warnings or errors about what I'm doing.

Environment

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

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 with the linked Godbolt reproduction using the latest DXC build and compare the accepted cast with the emitted SPIR-V access chain. Read the compiler's handling of array-to-scalar construct casts and determine whether the behavior should produce a diagnostic. Done means the behavior is corrected or its intended semantics are clearly established with coverage for this 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.