
51 Cal.2d 471 (1959)
DONALD A. COY, Petitioner,
v.
SUPERIOR COURT OF LOS ANGELES COUNTY, Respondent.
L. A. No. 25209. 
Supreme Court of California. In Bank.  
Feb. 2, 1959.
 John P. Brown and J. C. Radzik for Petitioner.
 Edmund G. Brown, Attorney General, William B. McKesson, District Attorney (Los Angeles), Ralph F. Bagley, Jere J. Sullivan, Lewis Watnick and Robert Lederman, Deputy District Attorneys, for Respondent.
 TRAYNOR J.
 An information filed by the District Attorney of Los Angeles County charged defendant with possessing narcotics in violation of Health and Safety Code, section 11500. His motion to set aside the information under Penal Code, section 995, was denied, and he now seeks a writ of prohibition to prevent his trial.
 On June 11, 1958, Officer Hill of the Los Angeles Police Department Narcotics Division received information from a *472 confidential informer that defendant was in possession of narcotics and that the room he occupied in a rooming house was being used as a "shooting gallery," a place where addicts congregate to use narcotics. The informer accompanied Officers Hill and Loreste to the neighborhood of the rooming house and pointed out the building and the room defendant occupied.
 An hour or so later, the officers entered the rooming house with the permission of the landlady, who accompanied them upstairs to defendant's room. As they approached the room, the door opened and defendant emerged dressed in a bathrobe. The landlady indicated that he was the person the officers had inquired about, and they placed him under arrest. The officers had no warrant. When the officers searched defendant's person after the arrest, they found narcotics and paraphernalia for their use in the pockets of his bathrobe. Defendant admitted that the narcotics were his, that he had purchased them that morning, and that he was on his way to the bathroom to take a fix.
 The informer was not present at the arrest, and took no other part than to supply information of defendant's possession and show the officers the location of defendant's residence.
 At the preliminary hearing, Officer Hill testified to the foregoing facts. He also testified that the informer had provided accurate information in the past that led to the arrest of three persons for unlawful possession of narcotics. He stated that in his opinion the informer was a reliable source of information and that he had relied upon him in making the arrest in the present case.
 On cross-examination, Officer Hill was asked the identity of the informer. The prosecution's objection was sustained on the ground that the informer's identity was privileged. (See Code Civ. Proc.,  1881, subd. 5.) After the cross-examination, the prosecution sought to introduce into evidence the narcotics found on defendant's person after the arrest. Defendant's objection on the ground that they had been obtained as a result of an illegal search and seizure was overruled. Defendant was committed and held for trial and his motion to set aside the commitment was denied.
 Defendant contends that since the identity of the informer was not disclosed, the officers could not justify the arrest on the basis of the informer's information; that the arrest was therefore illegal and the evidence obtained as a result thereof inadmissible; and that accordingly the writ should issue since *473 there was no competent evidence to support the commitment. (Priestly v. Superior Court, 50 Cal.2d 812, 815 [330 P.2d 39]; Badillo v. Superior Court, 46 Cal.2d 269, 271 [294 P.2d 23].)
 [1] In the Priestly case we held that "when the prosecution seeks to show reasonable cause for a search by testimony as to communications from an informer, either the identity of the informer must be disclosed when the defendant seeks disclosure or such testimony must be struck on proper motion of the defendant." (50 Cal.2d at 819.)
 [2] In the present case no motion to strike the officer's testimony was made after the identity of the informer was refused, and neither in his objection to the introduction of the narcotics in evidence nor by argument elsewhere in the record did defendant indicate that he was relying on the refusal to identify the informer to establish the illegality of the arrest and search. The magistrate did not err in sustaining the objection to the question asking the identity of the informer, for the prosecution was entitled to elect between disclosure and having the officer's testimony struck. It was incumbent on defendant to compel this election, however, by moving to strike or otherwise making his position clear. The prosecution may have had evidence other than the information of the informer to justify the search or it may have been willing to waive the privilege of nondisclosure if its case would otherwise fail, and it was entitled to an opportunity to produce such evidence or waive nondisclosure. It was not called upon to do so, however, while evidence of reasonable cause stood unchallenged in the record. To hold that the magistrate or trial court must strike the evidence on its own motion when the objection to it has not been called to its attention would open the door to needless repetitions of preliminary hearings. It would also permit the defendant to gamble on an acquittal at his trial secure in the knowledge that a conviction would be reversed on appeal and a new trial ordered. No undue burden is placed on the defendant by requiring him to make a motion to strike when the basis for excluding evidence theretofore properly admitted becomes apparent, and there is no basis for departing from the settled rule requiring such a motion (City of Venice v. Short Line Beach Land Co. (1919), 180 Cal. 447, 453 [181 P. 658]; Ballos v. Natural (1928), 93 Cal.App. 601, 608 [269 P. 972]; Brandt v. Krogh (1910), 14 Cal.App. 39, 56 [111 P. 275]; Fricke, California Criminal Evidence, 444- 445 (4th ed. 1957)) in the present situation. *474
 The alternative writ is discharged and the peremptory writ is denied.
 Gibson, C.J., Carter, J., Schauer, J., Spence, J., and McComb, J., concurred.
