Language:
كتاب الجنائز
23  
Funerals (Al-Janaa'iz)
(32)
Chapter: The statement of the Prophet ﷺ : "The deceased is punished because of the weeping (with wailing) of some of his relatives, if wailing was the custom of that dead person."
(32)
باب قَوْلِ النَّبِيِّ صلى الله عليه وسلم: «يُعَذَّبُ الْمَيِّتُ بِبَعْضِ بُكَاءِ أَهْلِهِ عَلَيْهِ» إِذَا كَانَ النَّوْحُ مِنْ سُنَّتِهِ
Sahih al-Bukhari 1285

Narrated Anas bin Malik:

We were (in the funeral procession) of one of the daughters of the Prophet (ﷺ) and he was sitting by the side of the grave. I saw his eyes shedding tears. He said, "Is there anyone among you who did not have sexual relations with his wife last night?" Abu Talha replied in the affirmative. And so the Prophet told him to get down in the grave. And so he got down in her grave.

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ، حَدَّثَنَا أَبُو عَامِرٍ، حَدَّثَنَا فُلَيْحُ بْنُ سُلَيْمَانَ، عَنْ هِلاَلِ بْنِ عَلِيٍّ، عَنْ أَنَسِ بْنِ مَالِكٍ ـ رضى الله عنه ـ قَالَ شَهِدْنَا بِنْتًا لِرَسُولِ اللَّهِ صلى الله عليه وسلم قَالَ وَرَسُولُ اللَّهِ صلى الله عليه وسلم جَالِسٌ عَلَى الْقَبْرِ ـ قَالَ فَرَأَيْتُ عَيْنَيْهِ تَدْمَعَانِ قَالَ ـ فَقَالَ ‏"‏ هَلْ مِنْكُمْ رَجُلٌ لَمْ يُقَارِفِ اللَّيْلَةَ ‏"‏‏.‏ فَقَالَ أَبُو طَلْحَةَ أَنَا‏.‏ قَالَ ‏"‏ فَانْزِلْ ‏"‏‏.‏ قَالَ فَنَزَلَ فِي قَبْرِهَا‏.‏
Reference : Sahih al-Bukhari 1285
In-book reference : Book 23, Hadith 45
USC-MSA web (English) reference : Vol. 2, Book 23, Hadith 374
  (deprecated numbering scheme)