Seems to be a bug of some sort because it's possible to power up Pokemon to level 40 by logging into multiple devices with the same account, or using airplane mode apparently works, by turning it on and then powering 3 times, and then turning it back off.
Not sure if it's bannable but I wouldn't risk it for an extra ~50 CP or something, even if it was a damage breakpoint. If you're considering powering up to 40 then keep your Pokemon at 38.5 tops.