# Undefined references warning for \AtEndDocument{\printbibliography}

Why does using \AtEndDocument{\printbibliography} cause the following warning?

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please rerun LaTeX.

Just to clarify: The references are displayed exactly like they should be. I'm just wondering why this warning is issued.

MWE:

\documentclass{book}

\usepackage{biblatex}
\AtEndDocument{\printbibliography}

\begin{document}

\cite{knuth:ct:c}

\end{document}


Note:

In case one wonders why this complicated syntax and not just using \printbibliography at the end of the document: This is just really convenient if used together with subfiles, see e.g. Bibliographies when using subfiles.

biblatex does a lot of cleaning up (also with respect to .aux files and warnings) in the \AtEndDocument hook. You don't get the warning if you issue
\AtEndDocument{\printbibliography}

before loading biblatex.