The properties of antihydrogen are expected to be identical to those of hydrogen, and any differences would constitute a profound challenge to the fundamental theories of physics. The most commonly discussed antiatom-based tests of these theories are searches for antihydrogen-hydrogen spectral differences (tests of CPT (charge-parity-time) invariance) or gravitational differences (tests of the weak equivalence principle). Here we, the ALPHA Collaboration, report a different and somewhat unusual test of CPT and of quantum anomaly cancellation. A retrospective analysis of the influence of electric fields on antihydrogen atoms released from the ALPHA trap finds a mean axial deflection of 4.1 ± 3.4 mm for an average axial electric field of 0.51 V mm(-1). Combined with extensive numerical modelling, this measurement leads to a bound on the charge Qe of antihydrogen of Q=(-1.3 ± 1.1 ± 0.4) × 10(-8). Here, e is the unit charge, and the errors are from statistics and systematic effects.