diff -ruN orig/codegen/valagtypemodule.vala vala.modified/codegen/valagtypemodule.vala
--- orig/codegen/valagtypemodule.vala	2016-02-09 19:48:28.000000000 +0100
+++ vala.modified/codegen/valagtypemodule.vala	2016-08-20 11:52:32.000000000 +0200
@@ -2186,12 +2186,13 @@
 		// to_string() on a gtype enum
 
 		push_line (expr.source_reference);
-		var temp_var = get_temp_variable (new CType ("GEnumValue*"), false, expr, false);
+		bool is_flags = ((Enum) ((EnumValueType) ma.inner.value_type).type_symbol).is_flags;
+		var temp_var = get_temp_variable (new CType (is_flags ? "GFlagsValue*" : "GEnumValue*"), false, expr, false);
 		emit_temp_var (temp_var);
 
 		var class_ref = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_ref"));
 		class_ref.add_argument (new CCodeIdentifier (get_ccode_type_id (ma.inner.value_type)));
-		var get_value = new CCodeFunctionCall (new CCodeIdentifier ("g_enum_get_value"));
+		var get_value = new CCodeFunctionCall (new CCodeIdentifier (is_flags ? "g_flags_get_first_value" : "g_enum_get_value"));
 		get_value.add_argument (class_ref);
 		get_value.add_argument ((CCodeExpression) get_ccodenode (((MemberAccess) expr.call).inner));
 
