Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision d3b7937ae7ab8afece0824b5729b7e86a9f0bd63)
+++ src/CodeGen/CodeGenerator.cc	(revision ae8b94256813adfe7582e0fabf10bdd0d8c7b864)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// CodeGenerator.cc --
+// CodeGenerator.cc -- 
 //
 // Author           : Richard C. Bilson
@@ -98,5 +98,5 @@
 		handleStorageClass( objectDecl );
 		output << genType( objectDecl->get_type(), mangleName( objectDecl ) );
-
+	
 		if ( objectDecl->get_init() ) {
 			output << " = ";
@@ -112,5 +112,5 @@
 		if ( aggDecl->get_name() != "" )
 			output << aggDecl->get_name();
-
+	
 		std::list< Declaration * > &memb = aggDecl->get_members();
 
@@ -118,12 +118,12 @@
 			output << " {" << endl;
 
-			cur_indent += CodeGenerator::tabsize;
+			cur_indent += CodeGenerator::tabsize; 
 			for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
-				output << indent;
+				output << indent; 
 				(*i)->accept( *this );
 				output << ";" << endl;
 			}
 
-			cur_indent -= CodeGenerator::tabsize;
+			cur_indent -= CodeGenerator::tabsize; 
 
 			output << indent << "}";
@@ -140,5 +140,5 @@
 		handleAggregate( aggregateDecl );
 	}
-
+  
 	void CodeGenerator::visit( EnumDecl *aggDecl ) {
 		output << "enum ";
@@ -146,5 +146,5 @@
 		if ( aggDecl->get_name() != "" )
 			output << aggDecl->get_name();
-
+	
 		std::list< Declaration* > &memb = aggDecl->get_members();
 
@@ -152,9 +152,9 @@
 			output << " {" << endl;
 
-			cur_indent += CodeGenerator::tabsize;
+			cur_indent += CodeGenerator::tabsize; 
 			for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
 				ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
 				assert( obj );
-				output << indent << mangleName( obj );
+				output << indent << mangleName( obj ); 
 				if ( obj->get_init() ) {
 					output << " = ";
@@ -164,17 +164,17 @@
 			} // for
 
-			cur_indent -= CodeGenerator::tabsize;
+			cur_indent -= CodeGenerator::tabsize; 
 
 			output << indent << "}";
 		} // if
 	}
-
+  
 	void CodeGenerator::visit( ContextDecl *aggregateDecl ) {}
-
+  
 	void CodeGenerator::visit( TypedefDecl *typeDecl ) {
 		output << "typedef ";
 		output << genType( typeDecl->get_base(), typeDecl->get_name() );
 	}
-
+  
 	void CodeGenerator::visit( TypeDecl *typeDecl ) {
 		// really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
@@ -216,5 +216,5 @@
 	}
 
-	void CodeGenerator::visit( Constant *constant ) {
+	void CodeGenerator::visit( Constant *constant ) { 
 		output << constant->get_value() ;
 	}
@@ -233,5 +233,5 @@
 						assert( arg != applicationExpr->get_args().end() );
 						if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
-
+	        
 							*arg = addrExpr->get_arg();
 						} else {
@@ -242,10 +242,10 @@
 						break;
 					}
-
+	      
 				  default:
 					// do nothing
 					;
 				}
-
+	    
 				switch ( opInfo.type ) {
 				  case OT_INDEX:
@@ -256,10 +256,10 @@
 					output << "]";
 					break;
-
+	      
 				  case OT_CALL:
 					// there are no intrinsic definitions of the function call operator
 					assert( false );
 					break;
-
+	      
 				  case OT_PREFIX:
 				  case OT_PREFIXASSIGN:
@@ -270,5 +270,5 @@
 					output << ")";
 					break;
-
+	      
 				  case OT_POSTFIX:
 				  case OT_POSTFIXASSIGN:
@@ -287,5 +287,5 @@
 					output << ")";
 					break;
-
+	      
 				  case OT_CONSTANT:
 				  case OT_LABELADDRESS:
@@ -306,5 +306,5 @@
 		} // if
 	}
-
+  
 	void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
 		if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
@@ -320,9 +320,9 @@
 					output << "]";
 					break;
-
+	      
 				  case OT_CALL:
 					assert( false );
 					break;
-
+	      
 				  case OT_PREFIX:
 				  case OT_PREFIXASSIGN:
@@ -334,5 +334,5 @@
 					output << ")";
 					break;
-
+	      
 				  case OT_POSTFIX:
 				  case OT_POSTFIXASSIGN:
@@ -341,5 +341,5 @@
 					output << opInfo.symbol;
 					break;
-
+  
 				  case OT_INFIX:
 				  case OT_INFIXASSIGN:
@@ -351,5 +351,5 @@
 					output << ")";
 					break;
-
+					
 				  case OT_CONSTANT:
 					// there are no intrinsic definitions of 0 or 1 as functions
@@ -369,5 +369,5 @@
 		} // if
 	}
-
+  
 	void CodeGenerator::visit( NameExpr *nameExpr ) {
 		OperatorInfo opInfo;
@@ -379,5 +379,5 @@
 		} // if
 	}
-
+  
 	void CodeGenerator::visit( AddressExpr *addressExpr ) {
 		output << "(&";
@@ -408,14 +408,14 @@
 		output << ")";
 	}
-
+  
 	void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
 		assert( false );
 	}
-
+  
 	void CodeGenerator::visit( MemberExpr *memberExpr ) {
 		memberExpr->get_aggregate()->accept( *this );
 		output << "." << mangleName( memberExpr->get_member() );
 	}
-
+  
 	void CodeGenerator::visit( VariableExpr *variableExpr ) {
 		OperatorInfo opInfo;
@@ -426,10 +426,10 @@
 		} // if
 	}
-
+  
 	void CodeGenerator::visit( ConstantExpr *constantExpr ) {
 		assert( constantExpr->get_constant() );
 		constantExpr->get_constant()->accept( *this );
 	}
-
+  
 	void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
 		output << "sizeof(";
@@ -442,15 +442,23 @@
 	}
 
-	void CodeGenerator::visit( AlignofExpr *sizeofExpr ) {
+	void CodeGenerator::visit( AlignofExpr *alignofExpr ) {
 		// use GCC extension to avoid bumping std to C11
 		output << "__alignof__(";
-		if ( sizeofExpr->get_isType() ) {
-			output << genType( sizeofExpr->get_type(), "" );
-		} else {
-			sizeofExpr->get_expr()->accept( *this );
+		if ( alignofExpr->get_isType() ) {
+			output << genType( alignofExpr->get_type(), "" );
+		} else {
+			alignofExpr->get_expr()->accept( *this );
 		} // if
 		output << ")";
 	}
 
+	void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) {
+		// use GCC builtin
+		output << "__builtin_offsetof(";
+		output << genType( offsetofExpr->get_type(), "" );
+		output << ", " << mangleName( offsetofExpr->get_member() );
+		output << ")";
+	}
+  
 	void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
 		output << "(";
@@ -464,5 +472,5 @@
 		output << ")";
 	}
-
+  
 	void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
 		output << "(";
@@ -474,5 +482,5 @@
 		output << ")";
 	}
-
+  
 	void CodeGenerator::visit( CommaExpr *commaExpr ) {
 		output << "(";
@@ -482,7 +490,7 @@
 		output << ")";
 	}
-
+  
 	void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
-
+  
 	void CodeGenerator::visit( TypeExpr *typeExpr ) {}
 
@@ -515,5 +523,5 @@
 			}
 		}
-		cur_indent -= CodeGenerator::tabsize;
+		cur_indent -= CodeGenerator::tabsize; 
 
 		output << indent << "}";
@@ -521,6 +529,6 @@
 
 	void CodeGenerator::visit( ExprStmt *exprStmt ) {
-		// I don't see why this check is necessary.
-		// If this starts to cause problems then put it back in,
+		// I don't see why this check is necessary. 
+		// If this starts to cause problems then put it back in, 
 		// with an explanation
 		assert( exprStmt );
@@ -572,5 +580,5 @@
 		switchStmt->get_condition()->accept( *this );
 		output << " ) ";
-
+		
 		output << "{" << std::endl;
 		cur_indent += CodeGenerator::tabsize;
@@ -592,5 +600,5 @@
 		} // if
 		output << ":\n";
-
+		
 		std::list<Statement *> sts = caseStmt->get_statements();
 
@@ -609,5 +617,5 @@
 			if ( ! branchStmt->get_target().empty() )
 				output << "goto " << branchStmt->get_target();
-			else {
+			else { 
 				if ( branchStmt->get_computedTarget() != 0 ) {
 					output << "goto *";
@@ -660,6 +668,6 @@
 
 	void CodeGenerator::visit( ForStmt *forStmt ) {
-		// initialization is always hoisted, so don't
-		// bother doing anything with that
+		// initialization is always hoisted, so don't 
+		// bother doing anything with that 
 		output << "for (;";
 
@@ -685,5 +693,5 @@
 	void CodeGenerator::visit( DeclStmt *declStmt ) {
 		declStmt->get_decl()->accept( *this );
-
+	
 		if ( doSemicolon( declStmt->get_decl() ) ) {
 			output << ";";
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision d3b7937ae7ab8afece0824b5729b7e86a9f0bd63)
+++ src/CodeGen/CodeGenerator.h	(revision ae8b94256813adfe7582e0fabf10bdd0d8c7b864)
@@ -61,4 +61,5 @@
 		virtual void visit( SizeofExpr *sizeofExpr );
 		virtual void visit( AlignofExpr *alignofExpr );
+		virtual void visit( OffsetofExpr *offsetofExpr );
 		virtual void visit( LogicalExpr *logicalExpr );
 		virtual void visit( ConditionalExpr *conditionalExpr );
