What causes pdfTeX warning (ext4) and how can I avoid it?

After some experiments, I figured out the cause of the problem; the following MWE allows to reproduce the problem:

\documentclass{article}
\usepackage{amsmath}
\usepackage{chngcntr}
\usepackage[pdfencoding = auto, psdextra, bookmarksdepth = 4]{hyperref}
\usepackage[noabbrev]{cleveref}

\counterwithin{equation}{section}

\begin{document}

\section{Test section}
\ref{equ:testa}~\ref{equ:testb}

\begin{subequations}
\begin{align}
a=b\label{equ:testa}
\end{align}
\end{subequations}

\section{Another test section}

\begin{subequations}
\begin{align}
c=d\label{equ:testb}
\end{align}
\end{subequations}

\end{document}

This code produces the following warning message:

warning (ext4): destination with the same identifier (name{equation.0.1}) has b
een already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                                  \fi \fi 
l.28 \end{document}
                   pdfTeX warning (ext4): destination with the same identifier 
(name{equation.0.1a}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                                  \fi \fi 
l.28 \end{document}
                   ] (./a.aux) )

The problem is here:

\usepackage[pdfencoding = auto, psdextra, bookmarksdepth = 4]{hyperref}
\usepackage[noabbrev]{cleveref}

\counterwithin{equation}{section}

Using \counterwithin after cleveref produces a bad interaction with hyperref+cleveref (if one comments out the line loading cleveref, the problem disappears). The solution is to move the line \counterwithin before loading cleveref:

\usepackage[pdfencoding = auto, psdextra, bookmarksdepth = 4]{hyperref}
\counterwithin{equation}{section}
\usepackage[noabbrev]{cleveref}

I believe that the problem is with counters. If we set the equation counter manually, then it results in such type of problems. Consider the following example:

\documentclass{article}

\usepackage{hyperref}
\usepackage{amsmath}

\begin{document}

   \begin{equation}
      \mbox{Equation is given number but nonumber restores the value of equation counter.}\nonumber
   \end{equation}

   \begin{equation}
      \mbox{This equation is assigned the same number as the previous one because counter was reset.} 
  \end{equation}

\end{document}

Here we get the warning. But If we use starred version of equation i.e. \begin{equation*}...\end{equation*}instead \nonumber as following:

\documentclass{article}

\usepackage{hyperref}
\usepackage{amsmath}

\begin{document}

   \begin{equation*}
      \mbox{Equation is not given any number.}
   \end{equation*}

   \begin{equation}
      \mbox{This equation is assigned unused number.} 
  \end{equation}

\end{document}

and there is no warning. Same happens for the MWE provided by Gonzalo Medina, subequation - counter being reset on section change. If we use align environment with /nonumber, then this problem does not occur. The reason being /nonumber is handled in a different way.


OK, I traced the problem down. Here is a minimal example that reproduces the problem:

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\begin{equation}\tag{1}
  1
\end{equation}
\begin{equation}
  2
\end{equation}
\end{document}

The problem arises when you use amsmath and hyperref packages, use the \tag command inside an equation environment, and use another equation environment later.

To avoid this problem, change the equation environment where you use \tag to gather. (No need to change equation environments where you don't use \tag.)