Issue 37: c-to-c: sizeof arg parenthesizing
diff --git a/examples/c-to-c.py b/examples/c-to-c.py
index ec2f04b..713cdd3 100644
--- a/examples/c-to-c.py
+++ b/examples/c-to-c.py
@@ -70,6 +70,10 @@
         operand = self._parenthesize_unless_simple(n.expr)
         if n.op == 'p++':
             return '%s++' % operand
+        elif n.op == 'sizeof':
+            # Always parenthesize the argument of sizeof since it can be 
+            # a name.
+            return 'sizeof(%s)' % self.visit(n.expr)
         else:
             return '%s%s' % (n.op, operand)
 
@@ -401,7 +405,13 @@
 def zz_test_translate():
     # internal use
     src = r'''
-int main(){}    '''
+int main(void)
+{
+  unsigned size;
+  size = sizeof(size);
+  return 0;
+}
+'''
     parser = c_parser.CParser()
     ast = parser.parse(src)
     ast.show()
diff --git a/examples/tests/test_c-to-c.py b/examples/tests/test_c-to-c.py
index eae0cce..83cc099 100644
--- a/examples/tests/test_c-to-c.py
+++ b/examples/tests/test_c-to-c.py
@@ -78,6 +78,15 @@
             int main() {

             }''')

     

+    def test_issue37(self):

+        self._assert_ctoc_correct(r'''

+            int main(void)

+            {

+              unsigned size;

+              size = sizeof(size);

+              return 0;

+            }''')

+

         

 

 if __name__ == "__main__":