# Tex Live 2016 bug: “! LaTeX Error: No counter 'd' defined.” [duplicate]

I have a file which compiles fine with TeX Live 2015, but which bugs on TeX Live 2016. When compiling with TeX Live 2016, (after I clean up all the non-source files) I get the following error:

! LaTeX Error: No counter 'd' defined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.27 \begin{defn}

?


Please have a look at the following minimal working example, in which I encounter this bug.

\documentclass{article}

\usepackage{amsthm}

\usepackage{aliascnt}

\usepackage[capitalize]{cleveref}

\def\defthm#1#2#3{%
%% Ensure all theorem types are numbered with the same counter
\newaliascnt{#1}{thm}
\newtheorem{#1}[#1]{#2}
\aliascntresetthe{#1}
%% This command tells cleveref's \cref what to call things
\crefname{#1}{#2}{#3}}

\newtheorem{thm}{Theorem}[section]
\crefname{thm}{Theorem}{Theorems}

\theoremstyle{definition}
\defthm{defn}{Definition}{Definitions}

\begin{document}

\begin{defn}
This definition causes trouble in TeX Live 2016, but not in TeX Live 2015.
\end{defn}

\end{document}