How do I determine the page in which manually added ToC entries are typeset?

The title says it all. Assume I use two \addtocontents in a document and I want to know whether or not their argument will be typeset in the same page of the ToC.

The simple idea of placing a \label and then using \pageref, as in

\documentclass{article}

\begin{document}

\pageref{a}\pageref{b}

\tableofcontents

\end{document}


fails and produces the expected warning:

LaTeX Warning: There were undefined references.

-
It works (on the third LaTeX run) if you \protect the \label commands. –  diabonas Apr 10 '12 at 18:33

..... fragile command in a moving argument...

\addtocontents{toc}{a\protect\label{a}}