I can't find in the spec where it mentions when a function with a return value must call return. Playing around in godbot with glslang it appears that a single return is required but not all control paths must return, it injects an undef in those cases?
Produces an error that the function must return a value.
int foo() {
if (true) {
return 1;
}
}
Compiles correctly with the end of the function return an OpUndef %int value.
int foo() {
if (true) {
return 1;
} else {
return 2;
}
}
Injects an OpUnreachable at the end of the function since all control paths return.
It seems like, there must be a single return call at any nesting level inside a function to be valid (according to glslang) and any other paths out of the function will return an OpUndef value.
I can't find in the spec where it mentions when a function with a return value must call
return. Playing around in godbot with glslang it appears that a singlereturnis required but not all control paths must return, it injects anundefin those cases?int foo() { }Produces an error that the function must return a value.
Compiles correctly with the end of the function return an
OpUndef %intvalue.Injects an
OpUnreachableat the end of the function since all control paths return.It seems like, there must be a single
returncall at any nesting level inside a function to be valid (according to glslang) and any other paths out of the function will return anOpUndefvalue.