add tag
In the newest version of PDFTeX, it looks like the behavior of the `\endwrite` token was changed somehow that the [method]( to access the token no longer work.

With some experiment:

\catcode`\  9
\endlinechar 32
\def \weird {    aaa \expandafter \weirda \expandafter { \iffalse } \fi }
\def \weirda #1  {  \expandafter \meaning  \noexpand }
(run with `tex`, not `pdftex`, it segmentation fault in the latter as if `\meaning` is applied to unsafe `\endwrite` before the patch) -- looks like the meaning remains `\outer macro:`, but now `\noexpand` no longer "works" with `\endwrite` token -- normally `\meaning <safe \endwrite>` would result in `\relax`.

Question: is there any way to create the `\endwrite` token in TeX/PDFTeX outside of `\write` context?

I don't see any obvious way because it's not possible to duplicate the `\endwrite` token, and section 1372 of TeX source code:


tokens will be unconditionally gobbled until `\endwrite` itself is seen.
Top Answer
Answering my own question: I suspect the answer is no.

As mentioned in a comment, the patch being applied is exactly that `\noexpand\endwrite` will not result in the safe `\endwrite` anymore.

An `end write token` will only be inserted when `write` starts, and it will be removed later (the only way I can think of to interrupt the `get token` loop is to use invalid (cat 15) characters, and that doesn't allow breaking out of the loop either). With `\noexpand` gone there's very little things that can be done with `\endwrite` -- in particular it doesn't look possible to duplicate it, the error recovery on encountering a forbidden token while scanning argument seems to just terminate the argument scanning (around paragraph 392 but I haven't read carefully).

Anyway, looking through occurrences of `scanner status ← normal`, the only occurrences within expandable primitives I can find are `\ifx`, `\noexpand`, `\string`, `\meaning`. `\noexpand` is now useless and the other 3 just throw away the token.

I manage to segmentation fault `tex` again by doing `\ifx\endwrite\a` (not particularly useful however):


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.