Skip to content

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

Closed

Description

@TheRealMJP

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.

Metadata

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