We study the regularity of smooth functions f defined on an open set of R n and such that, for certain integers p ≥ 2, the powers f p : x → (f (x)) p belong to a Denjoy-Carleman class CM associated with a suitable weight sequence M . Our main result is a statement analogous to a classic theorem of H. Joris on C ∞ functions: if a function f : R → R is such that both functions f p and f q with gcd(p, q) = 1 are of class CM on R, and if the weight sequence M satisfies the so-called moderate growth assumption, then f itself is of class CM . Various ancillary results, corollaries and examples are presented.