microsoft / microsoft/DirectXShaderCompiler

Arrays cast compiler error

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

Nobody has claimed this yet.

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

Description

HLSL compilers 5.1 and lower compiles this test without any type-cast errors. DXC returns error:
// Internal Compiler error: llvm::cast() argument of incompatible type!

run
dxc -T vs_6_0 test.hlsl

=========== test.hlsl ============

#define MAX_CLIPPINGPLANES_CASCADE_ 8

struct VSOUT
{
	float4 vPos:SV_Position;
	float4 afClipD[MAX_CLIPPINGPLANES_CASCADE_>>2]:SV_ClipDistance;
};

void castFunc(out float4 afClipD[MAX_CLIPPINGPLANES_CASCADE_>>2])
{
	[unroll]
	for (int n=0;n<MAX_CLIPPINGPLANES_CASCADE_;++n)
		((float[MAX_CLIPPINGPLANES_CASCADE_])afClipD)[n]=float(n*n);
}

VSOUT main(float4 pos:POSITION0)
{
	VSOUT ret;
	ret.vPos=1;
	castFunc(ret.afClipD);	
	return ret;
} 

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 issue with dxc -T vs_6_0 test.hlsl using the provided shader. Trace the compiler path handling the array cast and determine why it reaches the internal LLVM cast failure. Done means this input no longer reports an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.