dubious
dubious

Reputation: 217

Why does GLSL assume missing function would return a float?

Consider the simple GLSL ES 1.0 and 3.0 code

int i = f();

When f() is not defined, this produces 2 errors:

ERROR: 0:41: 'f' : no matching overloaded function found
ERROR: 0:41: '=' : cannot convert from 'const mediump float' to 'mediump int'

The first error is expected but the second is not.

Why is this assignment treated as if the undefined function f() returns a const mediump float? Is this some default in the overloading search? Is there some concept of a default function which returns a float?

The following code produces only the first error:

float j = f();

Upvotes: 1

Views: 62

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474266

A lot of compilers are not well optimized for generating error messages (and a lot of languages are not well optimized or specified for helping compilers generate better errors). Once they detect that something is wrong, any subsequent processing is based on wrong information.

As such, the general rule is to ignore all errors except the first. Once you fix that, compile again and see what it says.

Upvotes: 0

Related Questions