Skip to content

overly aggressive array bounds check for array size that is a spec constant expression #1783

@dneto0

Description

@dneto0

Sample vertex shader:

#version 450

layout(constant_id = 0) const uint a = 1;
layout(location = 0) out uint o;

void main() {
  uint arr[a+a];
  arr[0] = 1;
  arr[1] = 2;
  o = arr[1];
}

compiling to generate SPIR-V, I get this:

$glslangValidator  -V c.vert -o c.spv
c.vert
ERROR: c.vert:9: '[' :  array index out of range '1'
ERROR: c.vert:9: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.


SPIR-V is not generated for failed compile or link

Given that the spec constant is not known at compile time, it's too aggressive to error out saying that an array index of 1 is out of range.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions