Re: sscanf in conditional - what should happen?
Arne Goedeke <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
I took the liberty to add this as a testcase. I think the most reasonable behavior would be to initialize the variables to being UNDEFINED, regardless of the call to sscanf. I don't know how that could be done in the compiler. arne On 01/18/15 15:06, Chris Angelico wrote: > On Sun, Jan 18, 2015 at 11:40 PM, Arne Goedeke <[email protected]> wrote: >> Yes, it ought to be undefined. Can you produce a testcase? > > This is about as minimal as I can get it. > > int main() > { > string ext=".rar"; > { > string foo="oops!"; //This ends up in x > } > if (ext==".rar" || sscanf(ext,".r%d",int x)) > write("x should be an integer, is actually %O\n",x); > } > > On a current Pike 8.1, this has "oops!" in x. Likewise in 7.8.866 on Windows. > > ChrisA >