Re: sscanf in conditional - what should happen?
Arne Goedeke <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
Yes, it ought to be undefined. Can you produce a testcase?
arne
Maybe we can
On 01/18/15 11:26, Chris Angelico wrote:
> 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
>