microsoft / microsoft/DirectXShaderCompiler
Members with bitfields passed as arguments to atomic ops produce unhelpful errors
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
When a struct member with bitfield members is passed to an InterLocked* operation, it fails as it should, but the error message produced says that it's an inability to convert an integer to an integer reference, or in the case of groupshared that it can't cast across the memory types. Neither of these are accurate and could be very confusing to the user.
Steps to Reproduce
See https://github.com/microsoft/DirectXShaderCompiler/blob/main/tools/clang/test/SemaHLSL/atomics-on-bitfields.hlsl for pretty much all the examples. For the even greater ease, here is that test as currently written in godbolt: https://godbolt.org/z/Taa1rzj1z
Actual Behavior
For typed and structured buffers, this error is produced:
error: no matching function for call to 'InterlockedOr'
note: candidate function not viable: no known conversion from 'uint' to 'unsigned long long &' for 1st argument
For groupshared variables, this error is produced:
error: no matching function for call to 'InterlockedCompareStore'
note: candidate function not viable: no known conversion from '__attribute__((address_space(3))) uint' to 'unsigned long long' for 1st argument
Environment
- DXC version 1.8.2502
- Host Operating System Linux, MacOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tools/clang/test/SemaHLSL/atomics-on-bitfields.hlsl and run the listed bitfield atomic-operation cases to reproduce the diagnostics. Trace how these calls are diagnosed, then make the errors accurately identify the unsupported bitfield arguments and update the test expectations to demonstrate the corrected messages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100