Branch: Tag:


2015-01-31 12:57:54 by Arne Goedeke <>

Testsuite: added testcase for undefined variables in sscanf

The value of variables declared in sscanf calls is undefined if the
sscanf call does not actually happen. It is impossible to detect this at
compile time, so generating an error in cases where they are incorrectly
used is not an option. The behavior proposed by this testcase is to
always initialize them to UNDEFINED.

Thanks to Chris Angelico for bringing this issue up and providing a

7819:   test_any([[mixed a; sscanf("a93","%s%*x",a); return a]],"")   test_any([[mixed a; sscanf("a93","%*s%x",a); return a]],0xa93)   test_any([[mixed a; sscanf("f","f%n",a); return a]],1) + test_any([[ +  string y = "32"; +  { +  string foo = "bar"; +  } +  if (1 || sscanf(y, "%d", int x)) return !x; + ]], 1)      define(test_sscanf, [[    test_any([[$1 a = $3, b; string s = sprintf($2, a); sscanf(s, $2, b); return s == sprintf($2, b);]], 1)