In the standard inflationary scenario, primordial perturbations are adiabatic. The amplitudes of most types of isocurvature perturbations are generally constrained by current data to be small. If, however, there is a baryon-density perturbation that is compensated by a dark-matter perturbation in such a way that the total matter density is unperturbed, then this compensated isocurvature perturbation (CIP) has no observable consequence in the cosmic microwave background (CMB) at linear order in the CIP amplitude. Here, we search for the effects of CIPs on CMB power spectra to quadratic order in the CIP amplitude. An analysis of the Planck temperature data leads to an upper bound Δrms2≤7.1×10-3, at the 68% confidence level, to the variance Δrms2 of the CIP amplitude. This is then strengthened to Δrms2≤5.0×10-3 if Planck small-angle polarization data are included. A cosmic-variance-limited CMB experiment could improve the 1σ sensitivity to CIPs to Δrms2 9×10-4. It is also found that adding CIPs to the standard ΛCDM model can improve the fit of the observed smoothing of CMB acoustic peaks just as much as adding a nonstandard lensing amplitude.