xuxiandi / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Incorrect Function Scope #253

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
int f(int k) {
  int k = k + 3;
  return k;
}

void main() {
  gl_FragColor = vec4(f(100));
}

What is the expected output? What do you see instead?
This is legal. Angle claims k is redefined.

What version of the product are you using? On what operating system?
r887

Please provide any additional information below.
http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf 
Section 4.2.2

Original issue reported on code.google.com by kosmo...@gmail.com on 23 Nov 2011 at 11:22

GoogleCodeExporter commented 9 years ago
This is likely a spec bug.  See 
https://cvs.khronos.org/bugzilla/show_bug.cgi?id=8656 (auth required)

Original comment by dan...@transgaming.com on 28 Feb 2012 at 1:34

GoogleCodeExporter commented 9 years ago

Original comment by dan...@transgaming.com on 5 Mar 2012 at 3:42

GoogleCodeExporter commented 9 years ago

Original comment by nicolas....@gmail.com on 8 Mar 2012 at 9:28

GoogleCodeExporter commented 9 years ago
There is an apparent spec contradiction between the the grammar rules (on 
p.174) and the spec language in p.34.  

Based on discussions with the various spec authors, the general consensus is 
that that the line 'k=k+3'  should fail as a redeclaration. The grammar is 
correct in this case, and the body text "A function body has a scope nested 
inside the function’s definition." is suspect. If that is taken to mean that 
a function definition defines at least two scopes, then it is definitely wrong. 
This is because function_prototype already begins a new scope (for the function 
parameter names).  There is nesting occurring, but it starts between the 
function name and the parameter list, not between the parameter list and the 
function body.

Hopefully there will be eventual spec clarifications.

Closing as wontfix since we currently implement the desired behaviour. 

Original comment by dan...@transgaming.com on 21 Mar 2012 at 6:42

GoogleCodeExporter commented 9 years ago
Excellent. Thank you. I will fix my code to meet the projected spec change.

Original comment by kosmo...@gmail.com on 22 Mar 2012 at 3:08