Preprocessor hides doubles variable assignment in macro on Debian
Hi there,
I've encountered a strange bug where a newer version of Pike (commit 7303bc4c) is swallowing up some variable assignments. Specifically, when two variable assignments are used in combination with a macro.
I have the following code:
#define ERR_CONT(TYPE,CARR,FMT,ARGS ...) write(FMT, ARGS); write("\n");
int main() {
ERR_CONT(1, 1, "%s", "one");
ERR_CONT(1, 1, "%s %s", "one", "two");
ERR_CONT(1, 1, "%s %s %s", "one", "two", "three");
ERR_CONT(1, 1, "%s %d", "one", 2);
ERR_CONT(1, 1, "%s %d %d", "one", 2, 3);
ERR_CONT(1, 1, "%s %d %s", "one", 2, "three");
}
which when preprocessed using Pike v8.0 release 1116 on Debian 11, provides the expected result:
$ pike -E test2.pike
#line 1 "test2.pike"
int main() {
write( "%s" , "one" ); write("\n");;
write( "%s %s" , "one", "two" ); write("\n");;
write( "%s %s %s" , "one", "two", "three" ); write("\n");;
write( "%s %d" , "one", 2 ); write("\n");;
write( "%s %d %d" , "one", 2, 3 ); write("\n");;
write( "%s %d %s" , "one", 2, "three" ); write("\n");;
}
However, using the version compiled from 7303bc4c, the assignments with two variables do not compile as intended:
$ ~/pike/build/linux-5.10.0-26-amd64-x86_64/pike -E test2.pike
#line 1 "test2.pike"
int main() {
write( "%s" , "one" ); write("\n");;
write( "%s %s" , ); write("\n");;
write( "%s %s %s" , "one","two","three" ); write("\n");;
write( "%s %d" , ); write("\n");;
write( "%s %d %d" , "one",2,3 ); write("\n");;
write( "%s %d %s" , "one",2,"three" ); write("\n");;
}
As we can see, write( "%s %s" , ); write("\n");;
and write( "%s %d" , ); write("\n");;
are completely missing their variables.
Unfortunately I have no clue as to why.
I also went back to commit 43680aa7 and compiled from there, and same issue occurs.
Cheers, Josh
Edited by Joshua Rogers