This patch fixes the following bug: $ awk 'BEGIN{s="";a[1]=7;split("",b,split("",a));print a[1]}' 7 --- gawk-3.1.1/field.c.orig Mon May 13 14:56:04 2002 +++ gawk-3.1.1/field.c Mon May 13 14:55:17 2002 @@ -855,6 +855,16 @@ do_split(NODE *tree) * Skip the work if first arg is the null string. * Check after clearing the array, to preserve * correct semantics. + * + * But if sep is not FS, evaluate it, since it may have + * sideeffects. + */ + if ((sep->re_flags & FS_DFLT) == 0) + free_temp(tree_eval(sep->re_exp)); + /* + * FIXME: the above call should be also avoided in other + * cases when it's clear that sep has no side effects. + * (That would require an analysis during the compile time.) */ tmp = tmp_number((AWKNUM) 0); goto out;