diff --git a/spec/compiler/codegen/const_spec.cr b/spec/compiler/codegen/const_spec.cr
index f0ec927c688d22898cc742ac0c941969eda6f216..0c8342261bd0c62dd593213991de357302d3e96f 100644
--- a/spec/compiler/codegen/const_spec.cr
+++ b/spec/compiler/codegen/const_spec.cr
@@ -237,4 +237,22 @@ describe "Codegen: const" do
       Foo::BAR
       )).to_i.should eq(1)
   end
+
+  it "codegens constant that refers to another constant that is a struct" do
+    run(%(
+      struct Foo
+        X = Foo.new(1)
+        Y = X
+
+        def initialize(@value)
+        end
+
+        def value
+          @value
+        end
+      end
+
+      Foo::Y.value
+      )).to_i.should eq(1)
+  end
 end
diff --git a/src/compiler/crystal/codegen.cr b/src/compiler/crystal/codegen.cr
index 24e406e1d1811db5cb71359ea8f4167b9d006902..e3de37e9fab7088c73e219b0c53204cf679fc91b 100644
--- a/src/compiler/crystal/codegen.cr
+++ b/src/compiler/crystal/codegen.cr
@@ -908,12 +908,15 @@ module Crystal
           accept const.value
         end
 
+        if const.value.type.passed_by_value?
+          @last = load @last
+        end
+
         if LLVM.constant? @last
           LLVM.set_initializer global, @last
           LLVM.set_global_constant global, true
         else
           if const.value.type.passed_by_value?
-            @last = load @last
             LLVM.set_initializer global, LLVM.undef(llvm_type(const.value.type))
           else
             LLVM.set_initializer global, LLVM.null(type_of @last)