I believe scripture states otherwise And Step.
"38Then were there two thieves crucified with him, one on the right hand, and another on the left. 39And they that passed by reviled him, wagging their heads, 40And saying, Thou that destroyest the temple, and buildest it in three days, save thyself. If thou be the Son of God, come down from the cross. 41Likewise also the chief priests mocking him, with the scribes and elders, said, 42He saved others; himself he cannot save. If he be the King of Israel, let him now come down from the cross, and we will believe him. 43He trusted in God; let him deliver him now, if he will have him: for he said, I am the Son of God. 44The thieves also, which were crucified with him, cast the same in his teeth." Matthew 27:38-44
"Let this Christ, this King of Israel, come down now from the cross, that we may see and believe." Those crucified with him also heaped insults on him." Mark 15:32
Both of the thieves insulted Christ on the cross. But The thief that was saved finally came to a saving knowledge of Christ after he realized that Christ was truly the Son of God. This was unknown to him prior to his crucifixion.
As for Matthew 7:21-23, this is applicable to all those who only made profession of Christ but never had possession of Christ. This is why Jesus Christ said ye must be born again. The thief on the cross that was saved was born again because He confessed with His mouth and believed in His heart that Jesus Christ was His Savior. It was an instantaneous transaction. The thief knew that he could not save himself. He knew that his only hope was in Jesus Christ. And that is the same type of faith that all born again believers have.
Yes, declaration of belief is not sufficient. That's why you must believe in your heart. The circumcision of the heart is what saves an individual. Possession of Jesus Christ is believing on Him. Profession of Jesus Christ is believing in Him. Both are necessary for salvation. Just as Romans 10:9-10 states.
"9That if thou shalt confess with thy mouth the Lord Jesus, and shalt believe in thine heart that God hath raised him from the dead, thou shalt be saved. 10For with the heart man believeth unto righteousness; and with the mouth confession is made unto salvation."