microsoft / microsoft/DirectXShaderCompiler

`register` declaration applied to member of a `cbuffer` should be an error

Open
#7,638 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
You can apply bogus register declarations on members of a cbuffer as long as they correspond to the legacy constant registers, i.e. b#, c# or i#. Register spaces can be applied too.

Steps to Reproduce
https://hlsl.godbolt.org/z/5vr9xEd66

Actual Behavior
All of these do nothing and make no logical sense, but are accepted by DXC and emit no diagnostics at all.
Clang does error on almost all of them (with different reasons depending on register type), except if you only supply register space.

Environment

  • DXC version: 1.6+
  • Host Operating System: All

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 with the HLSL Compiler Explorer reproduction at https://hlsl.godbolt.org/z/5vr9xEd66 and compare DXC's diagnostics with Clang's for register declarations on cbuffer members. Trace the relevant parser or semantic-validation entry point, then add coverage showing that bogus register declarations and register spaces produce diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.