Sayyiduna Mu'adh bin Jabal (may Allah be pleased with him) narrates from the Prophet (peace and blessings be upon him) that he (peace and blessings be upon him) said: "On the Day of Resurrection, the one deprived of reason, the one who died in the period between prophets (fatrah), and the one who died in childhood will be brought. The one deprived of reason will say: 'O my Lord, had You given me reason, the one to whom You gave reason would not have been more fortunate through his reason than me.' The one who died in childhood will say: 'O my Lord, had You given me a lifespan, the one to whom You gave a lifespan would not have been more fortunate through his lifespan than me.' The one who died in the period between prophets will say: 'O my Lord, had a messenger come to me from You, the person to whom a covenant came from You would not have been more fortunate through Your covenant than me.' Then the Lord Almighty will say: 'I am giving you a command; will you obey Me?' They will say: 'Yes, by Your might, O Lord!' He will say: 'Go and enter Hell' - though if they entered it, it would not harm them at all - then portions (of flame) will come out at them from the Fire, and they will think that it has destroyed everything that Allah created. Then they will be commanded a second time, and they will turn back likewise. Then the Lord, the Mighty and Majestic, will say: 'I created you with My knowledge, and to My knowledge you will return.' Then the Fire will seize them."
Hadith Referenceالمعجم الكبير للطبراني / باب الميم / 17294