This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]