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

glsl: fails to reject shaders that use array-of-void #3881

Open
dneto0 opened this issue Feb 20, 2025 · 0 comments
Open

glsl: fails to reject shaders that use array-of-void #3881

dneto0 opened this issue Feb 20, 2025 · 0 comments

Comments

@dneto0
Copy link
Contributor

dneto0 commented Feb 20, 2025

Glslang compiles this to SPIR-V.

#version 320 es
void[2] foo() { }
void main() { foo(); }

The GLSL ES 3.2 spec says:

Functions that do not return a value must be declared as void. There is no default function return type. The keyword void cannot be used in any other declarations (except for empty formal or actual parameter lists), or an error results.

Glslang should fail compilation of the shader, and emit an error.

(In the generated spir-v foo returns an OpUndef of type array-of-two-void)

Glslang (correctly) rejects this shader:

void[2] bar() { }
void[2] foo() { return bar(); }
void main() { foo(); }

producing this error:

b.comp
ERROR: b.comp:3: 'return' : void function cannot return a value 
ERROR: b.comp:3: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.

The error is not quite right, because it implies foo is a 'void function'. That quality of the message was quite secondary.

This is super low priority for me. I was just messing around. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant