Fix some problematic optimizations on select, GCC compatibility
2 files changed, 10 insertions(+), 3 deletions(-)

M src/common/DynamicScope.h
M src/k3/FlowControl.cpp
M src/common/DynamicScope.h +1 -0
@@ 2,6 2,7 @@ 
 
 #include <vector>
 #include <unordered_map>
+#include <cstddef>
 
 std::unordered_map<void*,void*>* __dynscp_tls();
 void __dynscp_tls_dtor(void *key);

          
M src/k3/FlowControl.cpp +9 -3
@@ 5,6 5,7 @@ 
 #include "TypeAlgebra.h"
 #include "Native.h"
 #include "Conversions.h"
+#include "Reactive.h"
 #include "Invariant.h"
 
 namespace K3 {

          
@@ 152,7 153,9 @@ namespace K3 {
 						v = v.First();
 						vg = vg->GraphFirst();
 					}
-
+                    
+                    vg = ReactiveOperators::Impose::New(A0.node, vg);
+                    
 					return Specialization(vg, v);
 				} else {
 					t.GetRep().Diagnostic(LogErrors, this, Error::TypeMismatchInSpecialization, A0.result, "Select can accept a constant index");

          
@@ 226,14 229,17 @@ namespace K3 {
 
 		CTRef AtIndex::New(Type vectorTy, CTRef vector, CTRef index) {
 			Native::Constant *c;
-			if (index->Cast(c)) {
+            // constant propagation breaks reactive clock; disabled below
+			if (false && index->Cast(c)) {
 				assert(c->FixedResult().IsInt32());
 				int i = *(std::int32_t*)c->GetPointer();
 				auto svTy = vectorTy;
+                                
 				while (i--) {
 					vector = vector->GraphRest();
 					svTy = svTy.Rest();
 				}
+                                
 				// handle possible nil termination
 				if (svTy == vectorTy.First()) return vector;
 				else {

          
@@ 469,4 475,4 @@ namespace K3 {
 			Modulo(idx,lenc),lenc),"vector index",
 						 "Selects an element from the table according to index, using modulo addressing to wrap around the index");
 	}
-};
  No newline at end of file
+};