We consider a U(1) gauge theory on M4×T4 with background magnetic fluxes. We show that a theory including arbitrary fluxes can always be studied in a theory involving only diagonal fluxes by appropriate coordinate transformations. It is found that the number of independent magnetic fluxes is equal to the rank of the classical value of the field strength matrix, rank⟨F⟩. The number of massless zero modes induced from extra components of higher-dimensional gauge field (Wilson-line scalar field) is also determined by rank⟨F⟩. We explicitly confirm that the quantum corrections due to the matter fermion to the squared mass of the Wilson-line scalar field cancel out at the one-loop level. For this purpose, we derive the fermion mass spectrum on M4×T4 with arbitrary fluxes. By taking the flux diagonal basis, creation and annihilation operators for Kaluza-Klein quantum numbers are defined appropriately. Our results are easily generalized to the case of M4×T2n(n≥3). Published by the American Physical Society 2024