Work-around bug in GCC 4.4.5
[pspp] / src / data / casereader.c
index 98c10273b314dd4bbc4f81170e485136a828a756..adb6b6a909b134e815836aa75cbf0b1263d79b68 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009, 2010, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -118,25 +118,6 @@ casereader_clone (const struct casereader *reader_)
   return clone;
 }
 
-/* Makes a copy of ORIGINAL into *NEW1 (if NEW1 is non-null) and
-   *NEW2 (if NEW2 is non-null), then destroys ORIGINAL. */
-void
-casereader_split (struct casereader *original,
-                  struct casereader **new1, struct casereader **new2)
-{
-  if (new1 != NULL && new2 != NULL)
-    {
-      *new1 = casereader_rename (original);
-      *new2 = casereader_clone (*new1);
-    }
-  else if (new1 != NULL)
-    *new1 = casereader_rename (original);
-  else if (new2 != NULL)
-    *new2 = casereader_rename (original);
-  else
-    casereader_destroy (original);
-}
-
 /* Returns a copy of READER, which is itself destroyed.
    Useful for taking over ownership of a casereader, to enforce
    preventing the original owner from accessing the casereader
@@ -261,6 +242,19 @@ casereader_count_cases__ (const struct casereader *reader,
   struct casereader *clone;
   casenumber n_cases;
 
+  /* This seems to avoid a bug in Gcc 4.4.5 where, upon
+     return from this function, the stack appeared corrupt,
+     and the program returned to the wrong address.  Oddly
+     the problem only manifested itself when used in conjunction
+     with the ODS reader, in code such as:
+
+     GET DATA /TYPE=ODS ....
+     LIST.
+  */
+#if (__GNUC__ == 4 ) && (__GNUC_MINOR__ == 4)
+  volatile int x = 1; x++;
+#endif
+
   clone = casereader_clone (reader);
   n_cases = casereader_advance (clone, max_cases);
   casereader_destroy (clone);
@@ -331,7 +325,7 @@ casereader_advance (struct casereader *reader, casenumber n)
 
 
 /* Copies all the cases in READER to WRITER, propagating errors
-   appropriately. */
+   appropriately. READER is destroyed by this function */
 void
 casereader_transfer (struct casereader *reader, struct casewriter *writer)
 {