Index: libcfa/src/bits/locks.hfa
===================================================================
--- libcfa/src/bits/locks.hfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ libcfa/src/bits/locks.hfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -130,5 +130,5 @@
 		pthread_mutex_init(&lock, &mattr);
 
-		pthread_cond_init (&cond, 0p);
+		pthread_cond_init (&cond, (const pthread_condattr_t *)0p);  // workaround trac#208: cast should not be required
 		val = 0;
 	}
Index: libcfa/src/concurrency/kernel.cfa
===================================================================
--- libcfa/src/concurrency/kernel.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ libcfa/src/concurrency/kernel.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -1075,5 +1075,5 @@
 
 void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) {
-	$thread * thrd = kernel_data;
+	$thread * thrd = ( $thread * ) kernel_data;
 
 	if(thrd) {
Index: libcfa/src/concurrency/preemption.cfa
===================================================================
--- libcfa/src/concurrency/preemption.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ libcfa/src/concurrency/preemption.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -481,5 +481,5 @@
 	sigset_t oldset;
 	int ret;
-	ret = pthread_sigmask(0, 0p, &oldset);
+	ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset);  // workaround trac#208: cast should be unnecessary
 	if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
 
Index: libcfa/src/containers/list.hfa
===================================================================
--- libcfa/src/containers/list.hfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ libcfa/src/containers/list.hfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -22,5 +22,5 @@
 \
 static inline NODE& $tempcv_e2n(ELEM &node) { \
-	return node; \
+	return ( NODE & ) node; \
 } \
 \
@@ -187,5 +187,5 @@
 		$next_link(singleton_to_insert) = $next_link(list_pos);
 		if ($next_link(list_pos).is_terminator) {
-			dlist(Tnode, Telem) *list = $next_link(list_pos).terminator;
+			dlist(Tnode, Telem) *list = ( dlist(Tnode, Telem) * ) $next_link(list_pos).terminator;
 			$dlinks(Telem) *list_links = & list->$links;
 			$mgd_link(Telem) *list_last = & list_links->prev;
@@ -210,5 +210,5 @@
 		$prev_link(singleton_to_insert) = $prev_link(list_pos);
 		if ($prev_link(list_pos).is_terminator) {
-			dlist(Tnode, Telem) *list = $prev_link(list_pos).terminator;
+			dlist(Tnode, Telem) *list = ( dlist(Tnode, Telem) * ) $prev_link(list_pos).terminator;
 			$dlinks(Telem) *list_links = & list->$links;
 			$mgd_link(Telem) *list_first = & list_links->next;
@@ -275,5 +275,5 @@
 
 		if ( $prev_link(list_pos).is_terminator ) {
-			dlist(Tnode, Telem) * tgt_before = $prev_link(list_pos).terminator;
+			dlist(Tnode, Telem) * tgt_before = ( dlist(Tnode, Telem) * ) $prev_link(list_pos).terminator;
 			$dlinks(Telem) * links_before = & tgt_before->$links;
 			&incoming_from_prev = & links_before->next;
@@ -285,5 +285,5 @@
 
 		if ( $next_link(list_pos).is_terminator ) {
-			dlist(Tnode, Telem) * tgt_after = $next_link(list_pos).terminator;
+			dlist(Tnode, Telem) * tgt_after = ( dlist(Tnode, Telem) * ) $next_link(list_pos).terminator;
 			$dlinks(Telem) * links_after = & tgt_after->$links;
 			&incoming_from_next = & links_after->prev;
Index: libcfa/src/iostream.hfa
===================================================================
--- libcfa/src/iostream.hfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ libcfa/src/iostream.hfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -363,5 +363,5 @@
 	_Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }
 	_Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
-	_Istream_Cstr ignore( const char s[] ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
+	_Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
 	_Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; }
 	_Istream_Cstr wdi( unsigned int w, char s[] ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ libcfa/src/stdlib.hfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -232,5 +232,5 @@
 		size_t osize = malloc_size( ptr );				// current allocation
 		size_t nsize = dim * sizeof(T);					// new allocation
-		T * nptr = realloc( ptr, align, nsize );		// CFA realloc
+		T * nptr = alloc_align( ptr, align, nsize );	// CFA alloc_align
 		if ( nsize > osize ) {							// larger ?
 			memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage
@@ -243,5 +243,5 @@
 		size_t nsize = dim * sizeof(T);					// new allocation
 		size_t ndim = nsize / sizeof(T);				// new dimension
-		T * nptr = realloc( ptr, align, nsize );		// CFA realloc
+		T * nptr = alloc_align( ptr, align, nsize );		// CFA alloc_align
 		if ( ndim > odim ) {							// larger ?
 			for ( i; odim ~ ndim ) {
Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ src/Concurrency/Keywords.cc	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -510,5 +510,6 @@
 						new CastExpr(
 							new VariableExpr( func->get_functionType()->get_parameters().front() ),
-							func->get_functionType()->get_parameters().front()->get_type()->stripReferences()->clone()
+							func->get_functionType()->get_parameters().front()->get_type()->stripReferences()->clone(),
+							false
 						)
 					)
@@ -888,5 +889,5 @@
 			new SingleInit( new UntypedExpr(
 				new NameExpr( "get_monitor" ),
-				{  new CastExpr( new VariableExpr( args.front() ), arg_type ) }
+				{  new CastExpr( new VariableExpr( args.front() ), arg_type, false ) }
 			))
 		);
@@ -909,5 +910,5 @@
 					{
 						new SingleInit( new AddressExpr( new VariableExpr( monitors ) ) ),
-						new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )
+						new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) )
 					},
 					noDesignators,
@@ -946,5 +947,5 @@
 					return new SingleInit( new UntypedExpr(
 						new NameExpr( "get_monitor" ),
-						{  new CastExpr( new VariableExpr( var ), type ) }
+						{  new CastExpr( new VariableExpr( var ), type, false ) }
 					) );
 				})
@@ -970,5 +971,5 @@
 						new SingleInit( new VariableExpr( monitors ) ),
 						new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ),
-						new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )
+						new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) )
 					},
 					noDesignators,
Index: src/Concurrency/Waitfor.cc
===================================================================
--- src/Concurrency/Waitfor.cc	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ src/Concurrency/Waitfor.cc	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -384,5 +384,6 @@
 								decl_monitor
 							)
-						)
+						),
+						false
 					);
 
@@ -408,5 +409,5 @@
 			new CompoundStmt({
 				makeAccStatement( acceptables, index, "is_dtor", detectIsDtor( clause.target.function )                                    , indexer ),
-				makeAccStatement( acceptables, index, "func"   , new CastExpr( clause.target.function, fptr_t )                            , indexer ),
+				makeAccStatement( acceptables, index, "func"   , new CastExpr( clause.target.function, fptr_t, false )                     , indexer ),
 				makeAccStatement( acceptables, index, "data"   , new VariableExpr( monitors )                                              , indexer ),
 				makeAccStatement( acceptables, index, "size"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ),
@@ -531,5 +532,6 @@
 								decl_mask
 							)
-						)
+						),
+						false
 					),
 					timeout
Index: src/Parser/ExpressionNode.cc
===================================================================
--- src/Parser/ExpressionNode.cc	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ src/Parser/ExpressionNode.cc	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -427,15 +427,15 @@
 		if ( str[1] == '8' ) goto Default;				// utf-8 characters => array of char
 		// lookup type of associated typedef
-		strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char16_t", false );
+		strtype = new TypeInstType( Type::Qualifiers( ), "char16_t", false );
 		break;
 	  case 'U':
-		strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char32_t", false );
+		strtype = new TypeInstType( Type::Qualifiers( ), "char32_t", false );
 		break;
 	  case 'L':
-		strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "wchar_t", false );
+		strtype = new TypeInstType( Type::Qualifiers( ), "wchar_t", false );
 		break;
 	  Default:											// char default string type
 	  default:
-		strtype = new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char );
+		strtype = new BasicType( Type::Qualifiers( ), BasicType::Char );
 	} // switch
 	ArrayType * at = new ArrayType( noQualifiers, strtype,
Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -1216,6 +1216,8 @@
 			unify( castExpr->result, alt.expr->result, alt.env, needAssertions,
 				haveAssertions, openVars, indexer );
-			Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),
-				indexer, alt.env );
+			Cost thisCost =
+				castExpr->isGenerated
+				? conversionCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),	indexer, alt.env )
+				: castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),	indexer, alt.env );
 			PRINT(
 				std::cerr << "working on cast with result: " << castExpr->result << std::endl;
@@ -1698,9 +1700,23 @@
 
 				// unification run for side-effects
-				unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
+				bool canUnify = unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
+				(void) canUnify;
 				// xxx - do some inspecting on this line... why isn't result bound to initAlt.type?
 
-				Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
+				Cost thisCost = computeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(),
 					indexer, newEnv );
+
+				PRINT(
+					Cost legacyCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
+						indexer, newEnv );
+					std::cerr << "Considering initialization:";
+					std::cerr << std::endl << "  FROM: "; alt.expr->result->print(std::cerr);
+					std::cerr << std::endl << "  TO: ";   toType          ->print(std::cerr);
+					std::cerr << std::endl << "  Unification " << (canUnify ? "succeeded" : "failed");
+					std::cerr << std::endl << "  Legacy cost " << legacyCost;
+					std::cerr << std::endl << "  New cost " << thisCost;
+					std::cerr << std::endl;
+				)
+				
 				if ( thisCost != Cost::infinity ) {
 					// count one safe conversion for each value that is thrown away
Index: src/SynTree/Expression.h
===================================================================
--- src/SynTree/Expression.h	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ src/SynTree/Expression.h	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -206,5 +206,15 @@
   public:
 	Expression * arg;
-	bool isGenerated = true; // cast generated implicitly by code generation or explicit in program
+
+	// Inidicates cast is introduced by the CFA type system.
+	// true for casts that the resolver introduces to force a return type
+	// false for casts from user code
+	// false for casts from desugaring advanced CFA features into simpler CFA
+	// example
+	//   int * p;     // declaration
+	//   (float *) p; // use, with subject cast
+	// subject cast isGenerated means we are considering an interpretation with a type mismatch
+	// subject cast not isGenerated means someone in charge wants it that way
+	bool isGenerated = true;
 
 	CastExpr( Expression * arg, bool isGenerated = true );
Index: tests/.expect/init1.txt
===================================================================
--- tests/.expect/init1.txt	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
+++ tests/.expect/init1.txt	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -0,0 +1,47 @@
+error: No reasonable alternatives for expression Untyped Init Expression
+  Name: rx  InitAlternative: reference to signed int
+error: No reasonable alternatives for expression Untyped Init Expression
+  Name: px  InitAlternative: pointer to signed int
+error: No reasonable alternatives for expression Untyped Init Expression
+  Name: crx  InitAlternative: reference to float
+error: No reasonable alternatives for expression Untyped Init Expression
+  Name: cpx  InitAlternative: pointer to float
+init1.cfa:94:1 error: No reasonable alternatives for expression Generated Cast of:
+  Name: rx
+... to:
+  reference to signed int
+init1.cfa:97:1 error: No reasonable alternatives for expression Applying untyped:
+  Name: ?{}
+...to:
+  Generated Cast of:
+    Variable Expression: _retval_f_py: pointer to signed int
+  ... to:
+    reference to pointer to signed int
+  Name: px
+
+init1.cfa:104:1 error: No reasonable alternatives for expression Generated Cast of:
+  Name: crx
+... to:
+  reference to float
+init1.cfa:107:1 error: No reasonable alternatives for expression Applying untyped:
+  Name: ?{}
+...to:
+  Generated Cast of:
+    Variable Expression: _retval_f_py2: pointer to float
+  ... to:
+    reference to pointer to float
+  Name: cpx
+
+init1.cfa:114:1 error: No reasonable alternatives for expression Generated Cast of:
+  Name: s
+... to:
+  reference to instance of type T (not function type)
+init1.cfa:118:1 error: No reasonable alternatives for expression Applying untyped:
+  Name: ?{}
+...to:
+  Generated Cast of:
+    Variable Expression: _retval_anycvt: pointer to instance of type T (not function type)
+  ... to:
+    reference to pointer to instance of type T (not function type)
+  Name: s
+
Index: tests/avltree/avl1.cfa
===================================================================
--- tests/avltree/avl1.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/avltree/avl1.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -24,5 +24,5 @@
 tree(K, V) * create(K key, V value) {
   // infinite loop trying to resolve ... t = malloc();
-  tree(K, V) * t = malloc(sizeof(tree(K,V)));
+  tree(K, V) * t = ( tree(K, V) * ) malloc(sizeof(tree(K,V)));
   (*t){ key, value };
   return t;
Index: tests/bugs/66.cfa
===================================================================
--- tests/bugs/66.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/bugs/66.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -5,5 +5,5 @@
 
 int main() {
-	int * next = (void*)0;
+	int * next = 0p;
 	if( next ) {
 		return 1;
Index: tests/concurrent/signal/block.cfa
===================================================================
--- tests/concurrent/signal/block.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/concurrent/signal/block.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -82,5 +82,5 @@
 	if( !is_empty( cond ) ) {
 
-		$thread * next = front( cond );
+		$thread * next = ( $thread * ) front( cond );
 
 		if( ! signal_block( cond ) ) {
Index: tests/exceptions/conditional.cfa
===================================================================
--- tests/exceptions/conditional.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/exceptions/conditional.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -17,5 +17,5 @@
 };
 
-void num_error_msg(num_error * this) {
+const char * num_error_msg(num_error * this) {
     if ( ! this->msg ) {
         static const char * base = "Num Error with code: X";
Index: tests/exceptions/defaults.cfa
===================================================================
--- tests/exceptions/defaults.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/exceptions/defaults.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -13,5 +13,5 @@
 }
 
-char * get_log_message(log_message * this) {
+const char * get_log_message(log_message * this) {
 	return this->msg;
 }
@@ -28,10 +28,10 @@
 	// We can catch log:
 	try {
-		throwResume (log_message){(char *)"Should be printed.\n"};
+		throwResume (log_message){"Should be printed.\n"};
 	} catchResume (log_message * this) {
 		printf("%s", this->virtual_table->msg(this));
 	}
 	// But we don't have to:
-	throwResume (log_message){(char *)"Should not be printed.\n"};
+	throwResume (log_message){"Should not be printed.\n"};
 }
 
Index: tests/init1.cfa
===================================================================
--- tests/init1.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
+++ tests/init1.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -0,0 +1,120 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// init1.cfa -- tests of initializing pointer- and reference-typed variables and returns
+//
+// Author           : Michael Brooks
+// Created On       : Thu Jul 16 22:00:00 2020
+// Last Modified By : Michael Brooks
+// Last Modified On : Thu Jul 16 22:00:00 2020
+// Update Count     : 1
+//
+
+void f() {
+
+    //
+    // setup
+    //
+
+    float x = 3.14;
+
+    float & rx = x;
+    float * px = &x;
+
+    const float & crx = x;
+    const float * cpx = &x;
+
+    //
+    // sound initializations
+    //
+
+    char * str1 = "hi";
+    const char * str2 = "hi";
+
+    float & rx2 = rx;
+    float * px2 = px;
+
+    const float & crx2 = crx;
+    const float * cpx2 = cpx;
+
+    //
+    // unsound initializations
+    //
+
+    // mismatched referenced type
+    int & ry = rx;
+    int * py = px;
+
+    // would discard refered constness (same float is referenced)
+    float & ry2 = crx;
+    float * py2 = cpx;
+}
+
+//
+// sound returns
+//
+
+char * f_str1() {
+    return "hi";
+}
+
+const char * f_str2() {
+    return "hi";
+}
+
+float & f_rx2 () {
+    float & rx = *0p;
+    return rx;
+}
+
+float * f_px2 () {
+    float * px = 0p;
+    return px;
+}
+
+const float & f_crx2 () {
+    float & rx = *0p;
+    return rx;
+}
+
+const float * f_cpx2 () {
+    float * px = 0p;
+    return px;
+}
+
+//
+// unsound returns
+//
+
+int & f_ry() { 
+    float & rx = *0p;
+    return rx;               // mismatched referenced type
+}
+
+int * f_py() {
+    float * px = 0p;
+    return px;               // mismatched referenced type
+}
+
+float & f_ry2() {
+    const float & crx = *0p;
+    return crx;              // would discard refered constness (same float is referenced)
+}
+
+float * f_py2() {
+    const float * cpx = 0p;
+    return cpx;              // would discard refered constness (same float is referenced)
+}
+
+forall (dtype T, dtype S)
+T & anycvt( S & s ) {
+    return s;               // mismatched referenced type
+}
+
+forall (dtype T, dtype S)
+T * anycvt( S * s ) {
+    return s;               // mismatched referenced type
+}
Index: tests/io2.cfa
===================================================================
--- tests/io2.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/io2.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -121,5 +121,5 @@
 
 	[int, int, const char *, double] t3 = { 3, 4, "a", 7.2 };
-	sout | [ 3, 4, "a", 7.2 ];
+	sout | [ 3, 4, (const char*)"a", 7.2 ];             // workaround trac#207: the const cast should not be needed
 	sout | t3;
 	sepSetTuple( sout, " " );
Index: tests/searchsort.cfa
===================================================================
--- tests/searchsort.cfa	(revision 1d179399a54c3ddcecf129adeec6303b1492ddac)
+++ tests/searchsort.cfa	(revision b81fd952a5ac1533e8228e162fec0eac081416cf)
@@ -38,7 +38,7 @@
 	} // for
 	sout | nl;
-	for ( i; 0 ~ size ) {		// C version
+	for ( i; 0 ~ size ) {		// C version, returns void*
 		int key = size - i;
-		int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
+		int * v = ( int * ) bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
 		sout | key | ':' | *v | ", ";
 	} // for
