Changeset: 856e8aa5915f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=856e8aa5915f
Modified Files:
        sql/common/sql_types.c
Branch: Aug2011
Log Message:

sqltypeinit: gcc-4.6.1: error: array subscript is below array bounds

When you run below a pointer that points into an array, GCC will warn
about this.  To avoid this for running backwards in the array, make sure
the compiler "sees" that we start from an existing location, and hence
never get below that location in the array.


diffs (16 lines):

diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1365,7 +1365,11 @@ sqltypeinit(void)
                        sql_create_func("scale_up", "calc", "*", *u, *t, *t, 
SCALE_NONE);
        }
 
-       for (t = dates-1; t >= floats; t--) {
+       /* initial assignment to t is on purpose like this, such that the
+        * compiler (as of gcc-4.6) "sees" that we never go below the
+        * initial pointer, and hence don't get a
+        * error: array subscript is below array bounds */
+       for (t = floats + (dates - floats - 1); t >= floats; t--) {
                sql_create_func("power", "mmath", "pow", *t, *t, *t, SCALE_FIX);
                sql_create_func("floor", "mmath", "floor", *t, NULL, *t, 
SCALE_FIX);
                sql_create_func("ceil", "mmath", "ceil", *t, NULL, *t, 
SCALE_FIX);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to