Bug 33916 - Compiler accepts reserved operators % and %=
Summary: Compiler accepts reserved operators % and %=
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: All All
: low minor
Assignee: Chad Versace
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
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

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


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.