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, libgfortran] Bounds checking in date_and_time.c


Hello world,

this rather simple patch is the last installment of PR 34670, bounds
checking for array intrinsics.  With this out of the way, we can finally
close this PR.

I didn't make the check dependent on compile_options.bounds_checking
because I didn't see an advantage in checking an additional condition.
Also, the pre-existing behavior means that we don't really break any
existing programs, we just make a cryptic error message a bit easier
to read.  Finally, I didn't add a test case, because I don't think such
a trivial thing is worth the added running time.  I am, however, willing
to be corrected on the last issue.

Regression-tested on x86_64-unknown-linux-gnu.  OK for trunk?

	Thomas

2010-06-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/34670
	* intrinsics/date_and_time.c:  Replace assert with runtime_error
	when VALUE is too small.

Index: intrinsics/date_and_time.c
===================================================================
--- intrinsics/date_and_time.c	(Revision 160216)
+++ intrinsics/date_and_time.c	(Arbeitskopie)
@@ -280,8 +280,12 @@
       delta = GFC_DESCRIPTOR_STRIDE(__values,0);
       if (delta == 0)
 	delta = 1;
+      
+      if (unlikely (len < VALUES_SIZE))
+	  runtime_error ("Incorrect extent in VALUE argument to"
+			 " DATE_AND_TIME intrinsic: is %ld, should"
+			 " be >=%ld", (long int) len, (long int) VALUES_SIZE);
 
-      assert (len >= VALUES_SIZE);
       /* Cope with different type kinds.  */
       if (elt_size == 4)
         {

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