  We develop the procedures of gauging and ungauging, reveal their operational
meaning and propose their generalization in a systematic manner within the
framework of quantum error-correcting codes. We demonstrate with an example of
the subsystem Bacon-Shor code that the ungauging procedure can result in models
with unusual symmetry operators constrained to live on lower-dimensional
structures. We apply our formalism to the three-dimensional gauge color code
(GCC) and show that its codeword space is equivalent to the Hilbert space of
six copies of $\mathbb{Z}_2$ lattice gauge theory with $1$-form symmetries. We
find that three different stabilizer Hamiltonians associated with the GCC
correspond to distinct thermal symmetry-protected topological (SPT) phases in
the presence of the stabilizer symmetries of the GCC. One of the considered
Hamiltonians describes the Raussendorf-Bravyi-Harrington model, which is
universal for measurement-based quantum computation at non-zero temperature. We
also propose a general procedure of creating $D$-dimensional SPT Hamiltonians
from $(D+1)$-dimensional CSS stabilizer Hamiltonians by exploiting a relation
between gapped domain walls and transversal logical gates. As a result, we find
an explicit two-dimensional realization of a non-trivial fracton SPT phase
protected by fractal-like symmetries.
