Skip to content

DXC allows assigning to members of a const struct variable #2860

Closed
@TheRealMJP

Description

Hello, I just noticed that DXC will compile the following code without any errors:

struct MyData {
   float3 x[4];  
};

StructuredBuffer<MyData> DataIn;
RWStructuredBuffer<MyData> DataOut;

[numthreads(64, 1, 1)]
void CSMain(uint3 dispatchid : SV_DispatchThreadID)
{
    const MyData data = DataIn[dispatchid.x];
    data.x[0] = 1.0f;
    DataOut[dispatchid.x] = data;
}

I would expect the data.x[0] = 1.0f assignment to cause a compiler error since the data variable is marked as const.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions