It wasnarrated from 'Amr bin Shu'aib, from his father, from hisgrandfather that the Messenger of Allah (ﷺ) said:
"Whoevercommitsadultery with a slave woman or a free woman, his child isillegitimate, and he cannot inherit from him or be inherited from(i.e., this child cannot inherit from him)."
English reference: Vol. 4, Book 23, Hadith 2745
Arabic reference: Book 23, Hadith 2850