Bug 33916 - Compiler accepts reserved operators % and %=
Compiler accepts reserved operators % and %=
Status: RESOLVED FIXED
Product: Mesa
Classification: Unclassified
Component: glsl-compiler
git
All All
: low minor
Assigned To: Chad Versace
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-04 12:47 UTC by Chad Versace
Modified: 2011-02-08 09:40 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Fix for bug. (2.31 KB, patch)
2011-02-04 12:47 UTC, Chad Versace
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chad Versace 2011-02-04 12:47:26 UTC
Created attachment 42941 [details] [review]
Fix for bug.

Summary
-------
In GLSL < 1.30, operators % and %= are reserved, but the compiler accepts them anyway.

Attached is a fix for the bug.


Open Question
-------------
Should this bug be fixed? Fixing it may break applications that rely on this "feature".


Detail
------
For operator %, see section 5.9 of the GLSL ES 1.00, GLSL 1.10, and GLSL 1.20 spec. For operator %=, see section 5.8 of the GLSL ES 1.00, GLSL 1.10, and GLSL 1.20 spec.


Piglit Tests
------------
spec/glsl-1.00/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.10/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.20/compiler/arithmetic-operators/modulus-00.frag

spec/glsl-1.00/compiler/assignment-operators/modulus-assign-00.frag
spec/glsl-1.10/compiler/assignment-operators/modulus-assign-00.frag
spec/glsl-1.20/compiler/assignment-operators/modulus-assign-00.frag
Comment 1 Ian Romanick 2011-02-04 13:33:11 UTC
We should definitely fix this.  We don't want to encourage apps to assume that out-of-spec code will work.

I think the version check should be done in modulus_result_type.  This matches the way other 1.30 operators (e.g., the bit-wise operators) are handled.
Comment 2 Chad Versace 2011-02-08 09:40:27 UTC
Marking FIXED.

Ian, I followed your advice and placed the code in modulus_result_type().

Fixed by the following commit:
commit 82f994f3860ca05ff5550f32844b0f523d40b9ef
Author: Chad Versace <chad.versace@intel.com>
Date:   Fri Feb 4 12:18:56 2011 -0800

    glsl: Set operators '%' and '%=' to be reserved when GLSL < 1.30