KhronosGroup / KhronosGroup/glslang

Copying a struct with a bool produces invalid select statement

Open
#4,086 0 comments 0 reactions 0 assignees View on GitHub
bug sev:miscompile SPIR-V
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

https://godbolt.org/z/srbW3T8Tc

```glsl
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
#extension GL_EXT_buffer_reference2 : require

struct S1 { bool x; };

layout(set = 0, binding = 1) restrict readonly buffer SSBO {
S1 s1;
} InBuffer;

layout(buffer_reference) buffer MyBuffer {
S1 s1;
};

void main() {
MyBuffer payload;
payload.s1 = InBuffer.s1;
}
```

generates invalid SPIR-V

```
Expected bool scalar or vector type as condition: Select
%29 = OpSelect %uint %28 %uint_1 %uint_0
```

Contributor guide

Open the contributing guide

Research direction

Start with the Godbolt reproducer in the issue and inspect the generated SPIR-V around the reported OpSelect diagnostic. Done means the struct-copy example no longer generates invalid SPIR-V with a non-boolean select condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.