-
Notifications
You must be signed in to change notification settings - Fork 818
Open
Labels
bugBug, regression, crashBug, regression, crash
Milestone
Description
Description
cbuffer declarations can occur inside a namespace scope. DXC ignores it and the constant buffer elements must be referenced their local name without the namespace qualifier.
Steps to Reproduce
namespace ns {
cbuffer CB {
float a;
}
}
export float foo() {
// fails to compile:
// return ns::a;
return a;
}
The float value must be referenced as a in DXC instead of ns::a. Works correcty in Clang.
https://godbolt.org/z/GMzzMnh6s
BUT - if there are any other declarations inside the namespace, the ns::a reference is recognized, and so is just a!
namespace ns {
cbuffer CB {
float a;
}
float b; // added decl
}
export float foo() {
return ns::a + a; // no error
}
https://godbolt.org/z/xvx6zcb5q
Correct Behavior
DXC should recognize cbuffer declared within a namespace and it should create the constants with a qualified name. The constants cannot be referenced by unqualified names.
Environment
- DXC version: main as of 4/7/2025
Metadata
Metadata
Assignees
Labels
bugBug, regression, crashBug, regression, crash
Type
Projects
Status
Triaged