  In this paper, we systematically study gauge anomalies in bosonic and
fermionic weak-coupling gauge theories with gauge group G (which can be
continuous or discrete). We show a very close relation between gauge anomalies
and symmetry-protected trivial (SPT) orders [also known as symmetry-protected
topological (SPT) orders] in one-higher dimensions. Using such an idea, we
argue that, in d space-time dimensions, the gauge anomalies are described by
the elements in Free[H^{d+1}(G,R/Z)]\oplus H_\pi^{d+1}(BG,R/Z). The well known
Adler-Bell-Jackiw anomalies are classified by the free part of the group
cohomology class H^{d+1}(G,R/Z) of the gauge group G (denoted as
Free[H^{d+1}(G,\R/\Z)]). We refer other kinds of gauge anomalies beyond
Adler-Bell-Jackiw anomalies as nonABJ gauge anomalies, which include Witten
SU(2) global gauge anomaly. We introduce a notion of \pi-cohomology group,
H_\pi^{d+1}(BG,R/Z), for the classifying space BG, which is an Abelian group
and include Tor[H^{d+1}(G,R/Z)] and topological cohomology group
H^{d+1}(BG,R/Z) as subgroups. We argue that H_\pi^{d+1}(BG,R/Z) classifies the
bosonic nonABJ gauge anomalies, and partially classifies fermionic nonABJ
anomalies. Using the same approach that shows gauge anomalies to be connected
to SPT phases, we can also show that gravitational anomalies are connected to
topological orders (ie patterns of long-range entanglement) in one-higher
dimension.
