DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Incomplete type error when using typename of a template struct in Constant or StructuredBuffer

Open godlikepanos opened this issue 1 year ago • 1 comments

Description Using a typename of a template struct inside a Constant or Structured buffer throws an error: error: variable has incomplete type.

This is an example where it fails:

typedef Foo<float> FooFloat;
ConstantBuffer<FooFloat> x;

It appears to be a workaround if the template itself is being used:

ConstantBuffer<Foo<float> > x;

I assume the error is an omission.

Steps to Reproduce This is an example compute shader:

template<typename T>
struct TFoo
{
    T x;
};

#if 1
typedef TFoo<float> Foo; // ERROR
#else
#define Foo TFoo<float> // Workaround
#endif

ConstantBuffer<Foo> g_f;

[numthreads(1, 1, 1)]
void main()
{   
}

Compiled using: -T cs_6_8 -E main

Actual Behavior It works without error.

Environment

  • DXC version: trunk (40e27eb4)
  • Host Operating System: Any

godlikepanos avatar Mar 25 '24 16:03 godlikepanos

Triage notes: this is fallout from the HLSL 2021 changes. As there's a workaround for this, this is low priority for us to fix in DXC and is unlikely to be an issue in clang.

damyanp avatar Mar 25 '24 16:03 damyanp