Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIRV validation error with assign of nullptr to pointer variable #4754

Closed
dubiousconst282 opened this issue Jul 30, 2024 · 0 comments · Fixed by #4757
Closed

SPIRV validation error with assign of nullptr to pointer variable #4754

dubiousconst282 opened this issue Jul 30, 2024 · 0 comments · Fixed by #4757
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang kind:bug something doesn't work like it should

Comments

@dubiousconst282
Copy link
Contributor

Minimal repro:

[vk::push_constant] int* dest;

[numthreads(1)]
void ComputeMain(int tid : SV_DispatchThreadID) {
    int* ptr = nullptr;
    if (tid % 2 == 0) ptr = dest; // prevent const fold
    if (ptr) *ptr = 123;
}

Produces:

$ slangc -target spirv logs/shader-test/main.slang | spirv-val --target-env vulkan1.3
error: line 56: OpStore Pointer <id> '8[%ptr]'s type does not match Object <id> '28[%28]'s type.
  OpStore %ptr %28

The problem is that nullptr is being lowered into a void pointer as OpConvertUToPtr %_ptr_PhysicalStorageBuffer_void %ulong_0 instead of the target pointer type.

A workaround is to write (T*)0 instead of nullptr.

@ArielG-NV ArielG-NV added kind:bug something doesn't work like it should goal:client support Feature or fix needed for a current slang user. goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang and removed goal:client support Feature or fix needed for a current slang user. labels Jul 30, 2024
@csyonghe csyonghe added this to the Q3 2024 (Summer) milestone Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang kind:bug something doesn't work like it should
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants