microsoft / microsoft/DirectXShaderCompiler

C++11 enums don’t work as integer constants as expected

Open
#5,554 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem? Please describe.

Thanks to HLSL2021 I can share enumeration declarations between C++ and HLSL202x.

Bug Report: However whenever I declare the enum class HLSL does not complain until I actually try to use the scoped enum. Seems that enum class passes through your tokenizer unharmed, but then the rest of the logic is gone.

Describe the solution you'd like

For the compiler to support scope enum lookup enum_t:: without errors.

Describe alternatives you've considered

Not using scoped enums but a lot of my C++ code I want to expose to HLSL already does, so not fun.

Additional context

Here's a repro:
https://godbolt.org/z/1TdYh9E1a

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 scoped-enum lookup failure with the linked Godbolt example and trace how the DirectX Shader Compiler parses and resolves enum class references. Confirm that enum_t:: uses compile without errors while preserving the shared C++/HLSL declarations; the payload does not name a source file or test to run.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.