7

After some expected errors (missing \begin{document}, missing number treated as zero, missing $ inserted) the following code produces an infinite loop where LaTeX attempts to load the font ^^@^^@OT1+cmr, the font ^^@^^@^^@OT1+cmr, the font ^^@^^@^^@^^@OT1+cmr and so on until running out of grouping levels.

a
\count22
\par
\alpha

Changing \count22 to \count21 or \count23 makes the loop disappear. I'm quite puzzled.

1 Answers1

10

In latex.ltx we find

\countdef\m@ne=22 \m@ne=-1

and your code sets \count22 to zero, due to error recovery.

Changing the value of minus one to zero is not the best thing to do, I'm sure you agree with that.

In particular, the code for font loading sets \endlinechar\m@ne and this is the reason for all those ASCII NUL you see.

egreg
  • 1,121,712
  • Oops, of course! My question actually stemmed from trying to understand why \int_const:Nn \c_foo_int { foo } gives such a horrible loop, and \count22 came from \c_minus_one which is set equal to \m@ne. – Bruno Le Floch Sep 07 '16 at 17:16
  • @BrunoLeFloch Probably \c_minus_one should be directly set to -1 without relying on legacy code. – egreg Sep 07 '16 at 20:31
  • @egreg Not really possible: you can't \chardef a negative value so you have to use a \count – Joseph Wright Sep 08 '16 at 12:20
  • @JosephWright Yes, but you're not required to use \count22 – egreg Sep 08 '16 at 12:51