There are legally punishable sins mentioned in Quran. For example adultery. But some hadith claims that the Prophet withheld performing his duty as the leader of his community. 

> **[Sahih Bukhari Volume 008, Book 082, Hadith Number 812][1]**. Narrated By
> Anas bin Malik : While I was with the Prophet a man came and said, "O
> Allah's Apostle! I have committed a legally punishable sin; please
> inflict the legal punishment on me'.' The Prophet did not ask him what
> he had done. Then the time for the prayer became due and the man
> offered prayer along with the Prophet , and when the Prophet had
> finished his prayer, the man again got up and said, "O Allah's
> Apostle! I have committed a legally punishable sin; please inflict the
> punishment on me according to Allah's Laws." The Prophet said,
> "Haven't you prayed with us?' He said, "Yes." The Prophet said, **"Allah**
> **has forgiven your sin."** or said, "...your legally punishable sin."

This hadith is problematic. How can prophet know that someone's sin is forgiven by Allah?


> I am no different from the other messengers, **nor do I know what will
> happen to me or to you**. I only follow what is inspired to me. I am no
> more than a clear warner. [[Quran 46:9][2]]


  [1]: http://sunnah.com/bukhari/86/52
  [2]: https://quran.com/46/9