This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran, 4.2, committed] Fix off-by-one in IBCLR/IBSET arg checking.
- From: Brooks Moses <brooks dot moses at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 05 Mar 2007 00:43:20 -0800
- Subject: [patch, fortran, 4.2, committed] Fix off-by-one in IBCLR/IBSET arg checking.
This is a backport of a patch committed to mainline as obvious on
2007-01-09. Committed to 4.2 as obvious.
----------------------------------------------------------------
2007-03-05 Brooks Moses <brooks.moses@codesourcery.com>
* simplify.c (gfc_simplify_ibclr): Fix POS comparison.
(gfc_simplify_ibset): Same.
----------------------------------------------------------------
The bits in an N-bit integer are numbered from 0 to N-1; thus, this
error should be thrown when the POS argument is equal to N, as well as
when it's greater than N.
- Brooks
Index: simplify.c
===================================================================
--- simplify.c (revision 122539)
+++ simplify.c (working copy)
@@ -1295,7 +1295,7 @@
k = gfc_validate_kind (x->ts.type, x->ts.kind, false);
- if (pos > gfc_integer_kinds[k].bit_size)
+ if (pos >= gfc_integer_kinds[k].bit_size)
{
gfc_error ("Second argument of IBCLR exceeds bit size at %L",
&y->where);
@@ -1401,7 +1401,7 @@
k = gfc_validate_kind (x->ts.type, x->ts.kind, false);
- if (pos > gfc_integer_kinds[k].bit_size)
+ if (pos >= gfc_integer_kinds[k].bit_size)
{
gfc_error ("Second argument of IBSET exceeds bit size at %L",
&y->where);