You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompycparser.c_parserimportCParserfrompycparser.c_generatorimportCGenerator# Code is 30 nested `sizeof`s.code="int x = sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(int))))))))))))))))))))))))))))));"tree=CParser().parse(code)
print(tree) # the tree is correctprint(CGenerator().visit(tree)) # this never stops
# 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)
In the case where n.op is sizeof, n.expr is visited twice. When there are nested sizeofs, the leaf nodes will be visited an exponential number of times. (Although in reality such code wouldn't make sense)
I can create a PR with a few of my previous issues, but it might take a few days before I can work on this.
The text was updated successfully, but these errors were encountered:
Minimum example to reproduce:
The issue is within
CGenerator.visit_UnaryOp
:pycparser/pycparser/c_generator.py
Lines 61 to 72 in 61eac63
In the case where
n.op
issizeof
,n.expr
is visited twice. When there are nestedsizeof
s, the leaf nodes will be visited an exponential number of times. (Although in reality such code wouldn't make sense)I can create a PR with a few of my previous issues, but it might take a few days before I can work on this.
The text was updated successfully, but these errors were encountered: