Al-Ilmam bi-Ahadith al-Ahkam 441
وَعَن كريب مولَى ابْن عَبَّاس عَن عبد الله بن عَبَّاس رَضِيَ اللَّهُ عَنْهم أَنه مَاتَ ابْن لَهُ بقُدَيْد أَو بعسفان، فَقَالَ: يَا كريب، انْظُر مَا اجْتمع لَهُ من النَّاس. قَالَ: فَخرجت فَإِذا نَاس قد اجْتَمعُوا لَهُ، فَأَخْبَرته فَقَالَ: تَقول هم أَرْبَعُونَ؟ قَالَ قلت : نعم. قَالَ: أَخْرجُوهُ فَإِنِّي سَمِعت رَسُول الله ﷺ يَقُول: " مَا من (رجل) (مُسلم) (يَمُوت) فَيقوم عَلَى جنَازَته أَرْبَعُونَ رجلا، لَا يشركُونَ بِاللَّه شَيْئا، إِلَّا شفَّعهم الله فِيهِ ".
And from Kurayb, the freed slave of Ibn ʿAbbas, from ʿAbdullah ibn ʿAbbas, may Allah be pleased with them, that a son of his died at Qudayd or at ʿUsfan. He said: "O Kurayb, see how many people have gathered for him." He said: I went out, and people had gathered for him, and I told him. He said: "Would you say they are forty?" I said: "Yes." He said: "Bring him out, for I heard the Messenger of Allah ﷺ say: 'There is no (Muslim) (man) who (dies) and forty men who associate nothing with Allah stand [in prayer] over his funeral, except that Allah accepts their intercession for him.'"