(Yes, I'm aware of numerous historical exceptions. Those exceptions are traditionally considered not ideal.)
That’s incorrect.
If there is not a law the prosecutor or plaintiff can point to and say you broke, you can’t be prosecuted.
We wouldn’t need much legal process after a prosecution was initiated if it was impossible to prosecute without a law actually being broken.
(Yes, I'm aware of numerous historical exceptions. Those exceptions are traditionally considered not ideal.)