Chris Angelico
2015-01-18 10:26:45 UTC
Is this meant to be legal?
if (argv[1]=="#zero" || sscanf(argv[1],"#%d",int x))
{
... code using x ...
}
If the first part of the condition is true, x ought to be UNDEFINED. I
had code conceptually similar to this, but in the case where the first
condition held, x inexplicably had a completely different object
(probably the top of the stack; it was a Stdio.Stat object that I'd
used elsewhere). But am I trying to depend on unreasonable code here?
Breaking out the declaration to the line above solves the problem. I'm
just curious as to whether this ought to work or is pure chance.
ChrisA
if (argv[1]=="#zero" || sscanf(argv[1],"#%d",int x))
{
... code using x ...
}
If the first part of the condition is true, x ought to be UNDEFINED. I
had code conceptually similar to this, but in the case where the first
condition held, x inexplicably had a completely different object
(probably the top of the stack; it was a Stdio.Stat object that I'd
used elsewhere). But am I trying to depend on unreasonable code here?
Breaking out the declaration to the line above solves the problem. I'm
just curious as to whether this ought to work or is pure chance.
ChrisA