Abu Hurairah reported,

No, by the Lord of the Kaabah, I am not the one who said, "Whoever wakes up in a state of major ritual impurity should not fast that day." Muhammad ﷺ is the one who said it.

Ibn Majah 1702

Sahih

حدثنا أبو بكر بن أبي شيبة ومحمد بن الصباح قالا حدثنا سفيان بن عيينة عن عمرو بن دينار عن يحيى بن جعدة عن عبد الله بن عمرو القاري قال سمعت

أبا هريرة يقول

لا ورب الكعبة ما أنا قلت من أصبح وهو جنب فليفطر محمد ﷺ قاله

ابن ماجه 1702صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Fasting
Chapter
Man who wakes up in a state of janaba while intending to fast
Numbering
Darussalam 1702
Ibn Majah 1702