Anomalies and fermion masses in D dimensions