Fix 1509627: Work around a bug in gcc 4.1.2 and earlier. Compiling with -O2 or highe...
[synfig.git] / synfig-core / trunk / src / synfig / loadcanvas.cpp
index 760a231..8edd651 100644 (file)
@@ -290,6 +290,15 @@ CanvasParser::parse_integer(xmlpp::Element *element)
        return atoi(val.c_str());
 }
 
+// see 'minor hack' at the end of parse_vector() below
+// making this 'static' to give it file local scope
+// stops it working (where working means working around
+// bug #1509627)
+Vector &canvas_parser_vector_id(Vector &vector)
+{
+       return vector;
+}
+
 Vector
 CanvasParser::parse_vector(xmlpp::Element *element)
 {
@@ -332,7 +341,12 @@ CanvasParser::parse_vector(xmlpp::Element *element)
                else
                        error_unexpected_element(child,child->get_name());
        }
-       return vect;
+       // Minor hack - gcc 4.1.2 and earlier think that we're not using
+       // 'vect' and optimize it out at -O2 and higher.  This convinces
+       // them that we are really using it.
+       return canvas_parser_vector_id(vect);
+       // When the bug is fixed, we can just do this instead:
+       // return vect;
 }
 
 Color