
243 So.2d 144 (1971)
Jesse DANIELS, Petitioner,
v.
J.B. O'CONNOR, M.D., Superintendent, Florida State Hospital, Respondent.
No. 39481.
Supreme Court of Florida.
January 6, 1971.
*145 Richard S. Graham, Burke D. Chester and John E. Hankal, Daytona Beach, for petitioner.
Robert L. Shevin, Atty. Gen., W. Robert Olive, Jr. and Raymond L. Marky, Asst. Attys. Gen., for respondent.
ROBERTS, Chief Justice.
This cause is before the court on petition for the writ of habeas corpus filed by petitioner to obtain his release from the Florida State Hospital, a mental institution. The writ issued as prayed, and we now consider the cause on the issues made by the writ, the respondent's return thereto, and the petitioner's reply to the respondent's return.
The petitioner was indicted for the offense of rape in January of 1958 and, in due course, counsel was appointed to represent him as an indigent defendant. Pursuant to motion of his counsel, an investigation was conducted as to the defendant's mental condition and ability to stand trial, as authorized by Section 917.01, Florida Statutes, F.S.A. Thereafter, an order finding petitioner incompetent to stand trial and committing him to the Florida State Hospital was entered by the trial court.
The grounds for petitioner's attack on the legality of his commitment and detention are (1) that there was no legally competent evidence upon which to base the indictment for rape returned against him; and (2) that the statute under which he was committed, Section 917.01, supra, is unconstitutional on due process and equal protection grounds. Contentions made in his petition respecting inadequate representation by court-appointed counsel and the illegality of Section 917.01 as an unconstitutional delegation of judicial power were withdrawn in petitioner's reply to the respondent's return, the respondent having conceded that petitioner is entitled to a judicial hearing on the question of his sanity vel non at the present time.
We have carefully considered the question of whether the court may or should, in habeas corpus proceedings, authorize an inquiry into the facts upon which the grand jury relied in returning an indictment against the accused in order to determine whether the petitioner is illegally restrained of his liberty by virtue of such indictment. We have concluded that the fact that the accused is being held in a mental hospital awaiting trial upon the indictment for rape at such time as he is restored to his sanity does not, in our opinion, require us to make an exception to our rule of long standing that "the use of the writ of habeas corpus to test the sufficiency of the evidence upon which a charge may have been based is not sanctioned by this court." Sullivan v. State ex rel. McCrory, Fla. 1951, 49 So.2d 794, 797, and cases cited.
The decision relied upon by petitioner, State ex rel. Price v. Stone, 1937, 128 Fla. 637, 175 So. 229, held that, upon habeas corpus, the court "will examine the legal sufficiency of the alleged facts to make out a crime * * *." It was noted also that, when an accused is being held under a commitment issued on a preliminary hearing before a committing magistrate, the court may inquire into the actual facts relied upon to support the charge. The reason for this exception to the general rule is that the existence of "good grounds"  that is, probable cause  for holding an accused under a magistrate's commitment is essential to the magistrate's jurisdiction to make the commitment. See Sullivan v. State, supra. In the Stone case the accused was being held under an information filed against him by the prosecuting attorney; and the court, in accordance with the general rule referred to above, *146 merely examined the information to determine whether the facts alleged were legally sufficient to charge a crime. Concluding that no crime was alleged therein, the prisoner was discharged. It does not, therefore, constitute authority for the exception to the general rule herein sought by petitioner.
Finding that the contention here made by petitioner in this respect is supported neither by reason nor by authority, it cannot be sustained.
The thrust of petitioner's argument respecting the claimed denial of equal protection is that persons adjudged to be mentally incompetent in civil proceedings instituted under the provisions of Chapter 394, Florida Statutes, F.S.A., may be released to the care, custody and control of any responsible person who undertakes to assume the care and maintenance of the incompetent. See Sections 394.09 and 394.22(11)(c), Florida Statutes, F.S.A. He directs our attention also to Rule 1.460(a) of the Rules of Criminal Procedure, 33 F.S.A. (Section 919.11, Florida Statutes, F.S.A.) providing that a person who has been tried and found not guilty of a criminal charge by reason of insanity may be placed under the care and custody of his friends or may be discharged. The petitioner contends that, insofar as Section 917.01 authorizes the commitment, automatically, of any insane accused person to a mental institution without a judicial determination that he is dangerous to himself or others, it is a denial of equal protection.
It is well settled that the equal protection clause is violated only when the classification made by an act is arbitrary and unreasonable. When the differences in treatment between those included and those excluded from the class bear a real and substantial relation to the purposes sought to be attained by the act, the classification is valid as against an attack under the equal protection clause. See State v. Andersen, Fla. 1968, 208 So.2d 814; Finlayson v. Conner, Fla. 1964, 167 So.2d 569.
The distinction between a class of persons who have been accused of crime by an indictment valid on its face and have been found incompetent to stand trial, and a class of persons who have merely been adjudged incompetent under the civil procedures prescribed by Chapter 394, supra, is abundantly clear. The interest of the State in the safekeeping of the accused until such time as he may be brought to trial to establish his guilt or innocence of the charge undoubtedly accounts for the failure of the Legislature to authorize his release into private custody or his discharge; and, in our opinion, this provides a valid and reasonable basis for the classification. For the same reason, there is a clear distinction between the class of persons of which the petitioner is one, and a class of persons who have been acquitted of a criminal offense by reason of insanity.
The case relied upon by petitioner, Baxstrom v. Herold, 383 U.S. 107, 86 S.Ct. 760, 15 L.Ed.2d 620, is distinguishable on its facts. There a person convicted of crime was found to be insane while serving his term and was transferred to the prison hospital. Near the end of his term a hearing was held in which it was found that he required further mental care and treatment and should remain in the prison hospital, as required by the applicable New York statute. It was Baxstrom's contention that he had the right to be placed in a civil institution unless it was shown that he was dangerous to others. In upholding his contention, the Supreme Court said that "there is no conceivable basis for distinguishing the commitment of a person who is nearing the end of a penal term from all other civil commitments." This case is, then, not authoritative here, since the facts are in no wise the same.
Accordingly, the petitioner's contention respecting denial of equal protection cannot be sustained.
Nor can we agree that petitioner has been denied due process of law. He contends that his detention without proof *147 beyond a reasonable doubt that he committed the crime for which he was indicted and without proof beyond a reasonable doubt that he constitutes a danger to society if allowed to remain at liberty is such a denial. Petitioner has overlooked the fact that the purpose of Section 917.01, supra, is to protect the accused  to make sure that he will be able to assist his counsel in preparing the best defense possible to the crime with which he is charged. See State ex rel. Deeb v. Campbell, 1936, 123 Fla. 894, 167 So. 805, in which it was noted that a mentally ill accused "might mislead his counsel as to facts, misinform them as to his relations with other actors in the legal drama, and be utterly unreliable as a witness in his own behalf." Under Section 917.01, as at common law, a hearing upon the issue of an accused's ability to stand trial is obligatory if a "reasonable doubt" is raised as to the defendant's sanity. Brock v. State, Fla. 1954, 69 So.2d 344. It was there held also that, when the protection of the statute is invoked, the burden is on the accused to show insanity by a preponderance of the evidence. 69 So.2d at page 346. The question of whether the evidence on this question was sufficient to inform the judicial conscience definitely of the insanity vel non of the accused is reviewable by an appellate court. Deeb v. State, 1935, 118 Fla. 88, 158 So. 880, 882.
It can thus be seen that the question of whether the accused is guilty or innocent of the charge made against him in the indictment is irrelevant to the question of whether he is entitled to the protection afforded by Section 917.01, supra. And, as noted above, it appears to be a reasonable restraint upon the liberty of a person accused of crime but not competent to stand trial to hold him in protective custody until such time as his sanity may be restored. Here, again, no denial of due process is shown.
We find, therefore, that Section 917.01 is not susceptible to the attacks made against it on constitutional grounds.
Respondent has conceded that the petitioner is entitled to a hearing on the question of whether his sanity has now been restored before the court under whose order he was committed and is being detained, and we agree. Accordingly, the writ heretofore issued is discharged, but without prejudice to the right of petitioner to apply to the trial court in appropriate proceedings to obtain an adjudication of his sanity vel non and ability to stand trial, and to have an immediate hearing concerning same. Further if it should be determined that he is not sufficiently recovered to stand trial now, he is entitled at reasonable intervals, to be determined by the trial judge, to have the question reconsidered.
It is so ordered.
CARLTON and BOYD, JJ., and DREW, J. (retired), concur.
ERVIN, J., dissents with opinion.
ERVIN, Justice (dissenting):
Under the circumstances here appearing and the doubtful validity of F.S. Section 917.01 F.S.A., I believe an evidentiary hearing is in order and that we should proceed to determine the merits both as to law and facts.
