Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision db6cdc0f7e39fa424be65d849107ecd0c1e8e90b)
+++ src/CodeGen/CodeGenerator.cc	(revision 25b0fde212ca4f2989674f4c453738a67d543323)
@@ -290,5 +290,9 @@
 					if ( obj->get_init() ) {
 						obj->get_init()->accept( *visitor );
-						last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival();
+						Expression* expr = ((SingleInit *)(obj->init))->value;
+						while ( auto temp = dynamic_cast<CastExpr *>(expr) ) {
+							expr = temp->arg;
+						}
+						last_val = ((ConstantExpr *)expr)->constant.get_ival();
 					} else {
 						output << ++last_val;
Index: tests/enum_tests/.expect/anonymous.txt
===================================================================
--- tests/enum_tests/.expect/anonymous.txt	(revision 25b0fde212ca4f2989674f4c453738a67d543323)
+++ tests/enum_tests/.expect/anonymous.txt	(revision 25b0fde212ca4f2989674f4c453738a67d543323)
@@ -0,0 +1,1 @@
+17
Index: tests/enum_tests/anonymous.cfa
===================================================================
--- tests/enum_tests/anonymous.cfa	(revision 25b0fde212ca4f2989674f4c453738a67d543323)
+++ tests/enum_tests/anonymous.cfa	(revision 25b0fde212ca4f2989674f4c453738a67d543323)
@@ -0,0 +1,8 @@
+#include <stdio.h>
+enum(unsigned long int ) { nthreads = 17 };
+
+int main() {
+    printf("%lu", nthreads);
+}
+
+
