microsoft / microsoft/DirectXShaderCompiler

Non-const static data members of templated structs fail to compile

Open
#6,073 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
As the title describes. A non-const static data member in a templated struct will fail to compile. Having a non-const static data member in a non-templated struct works just fine as demonstrated here https://shader-playground.timjones.io/86034155d4699032dcecce2b676f2f4d. And having a const static data member in a templated struct works just fine as demonstrated here https://shader-playground.timjones.io/a65880bc84396a5f9420e41956817761

Steps to Reproduce
The following is a minimal example https://shader-playground.timjones.io/9cb247ff54bf1ee0c6bdaa960cb83f9d.

Actual Behavior
Compiler outputs "Declaration may not be in a Comdat!
i32* @"\01?Num@?$Test@$0CK@@@2HA"

Expected Behaviour
I would expect this to compile

Environment

  • DXC version 1.7.2308.12
  • Host Operating System Windows 10 Pro 22H2

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 minimal example from the linked shader-playground case and compare it with the working non-templated and const-static examples. Trace how the compiler handles the templated non-const static member and its Comdat declaration; done means the reported example compiles without the "Declaration may not be in a Comdat" error.

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.