microsoft / microsoft/DirectXShaderCompiler
Incomplete type error when using typename of a template struct in Constant or StructuredBuffer
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
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
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 by compiling the provided compute shader with DXC using -T cs_6_8 -E main and reproduce the incomplete-type error. Trace how typedefs of template structs are handled when used as ConstantBuffer or StructuredBuffer element types, then add coverage showing the typedef form behaves like the direct template form.
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
- 35/100