]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use NULL as default C value for nullable structs
authorLuca Bruno <lucabru@src.gnome.org>
Sun, 25 Dec 2011 12:43:28 +0000 (13:43 +0100)
committerJürg Billeter <j@bitron.ch>
Tue, 31 Jan 2012 13:02:29 +0000 (14:02 +0100)
Fixes bug 665904.

codegen/valaccodebasemodule.vala

index f5ca0c0bb05318bb5b9a6e84328ea4c511409d98..8df596643f7c9cc8583052d953d8057a912fc90f 100644 (file)
@@ -5448,7 +5448,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        public CCodeExpression? default_value_for_type (DataType type, bool initializer_expression) {
                var st = type.data_type as Struct;
                var array_type = type as ArrayType;
-               if (type.data_type != null && get_ccode_default_value (type.data_type) != "") {
+               if (type.data_type != null && !type.nullable && get_ccode_default_value (type.data_type) != "") {
                        return new CCodeConstant (get_ccode_default_value (type.data_type));
                } else if (initializer_expression && !type.nullable &&
                                   (st != null || (array_type != null && array_type.fixed_length))) {