This line (yes, really, just a "), results in an infinite loop with sdcc-sdcc test.c, the tested version is mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.0 #11528 (Linux)
I can reproduce the issue on my Debian GNU/Linux system using SDCC 4.0.2 #11640 compiled using flex 2.6.4.
A closer look shows that in SDCC.lex, the code for scanning string literals assumes that flex input() return EOF at the end of the file. But gdb shows that it instead returns 0 (and calls yywrap().
This problem is specific to flex 2.6.4, with flex 2.5.4, we get EOF, and SDCC works as expected.
I have no idea what input() should do. The only information I found in the flex manual was in the "Lex and POSIX" section:
Looks like flex won't change back to EOF (despite their documentation today still claiming that EOF is returned). And apparently returning 0 is ok by POSIX.
As of [r13827], SDCC should work with both EOF-returning and 0-returning lex.
I can reproduce the issue on my Debian GNU/Linux system using SDCC 4.0.2 #11640 compiled using flex 2.6.4.
A closer look shows that in SDCC.lex, the code for scanning string literals assumes that flex input() return EOF at the end of the file. But gdb shows that it instead returns 0 (and calls yywrap().
This problem is specific to flex 2.6.4, with flex 2.5.4, we get EOF, and SDCC works as expected.
I have no idea what input() should do. The only information I found in the flex manual was in the "Lex and POSIX" section:
This text is the same in both the flex 2.6.4 and 2.5.4 manuals.
P.S.: I found this Debian bug report abut the undocumented change in flex behaviour:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415
P.P.S.: I opened an issue for flex:
https://github.com/westes/flex/issues/448
Last edit: Philipp Klaus Krause 2020-06-03
Looks like flex won't change back to EOF (despite their documentation today still claiming that EOF is returned). And apparently returning 0 is ok by POSIX.
As of [r13827], SDCC should work with both EOF-returning and 0-returning lex.
Related
Commit: [r13827]