Dylann Roof, the man accused of a shooting spree that left nine people dead at a historic black church in Charleston on Wednesday night, should not have been able to get a gun.

Federal law prohibits people with pending felony charges from obtaining firearms. In February, Roof was arrested and later charged with felony possession of Suboxone, a narcotic prescription drug. He was released, and  the case is pending.

Because of his criminal record, Roof would not have been able to buy a gun from a store. Federally licensed gun dealers are required to run background checks on gun purchasers, and Roof’s pending charges should have turned up as a red flag.

But Roof didn’t need to go to a dealership. According to his uncle, Roof received a .45-caliber pistol from his father in April for his birthday, Reuters reports.

Will the Charleston, S.C., shooting change the way Americans think about guns? (Pamela Kirkland/The Washington Post)

South Carolina is one of 40 states that do not require background checks for private gun transactions, like the one that allegedly took place between Roof and his father. Gun control activists call this the “private sale” loophole.

It’s illegal to give guns to felons or people with felony indictments — but that’s only if you know about their criminal records. In South Carolina, you don’t have to ask, so private citizens can more or less freely exchange guns.

If prosecutors can show that the father knew about Roof’s indictment but gave him the gun anyway, Roof’s father could face up to 10 years in prison.

In contrast, ten states and the District of Columbia have closed the private sale loophole by requiring background checks for nearly all gun transfers. Anyone trying to sell or give Roof a gun would have had to take him to a licensed dealership or a law enforcement office to complete the transaction. (Many of these states have exceptions for people giving guns to family members, though.)

During his news conference addressing the shooting of nine people in a Charleston, S.C. church, President Obama issued a stern message on gun violence. (AP)

Other states deal with private transactions by requiring buyers to get a gun purchasing license, which involves passing a background check. Private sellers are supposed to check for this license before they sell a gun to someone.

It’s unclear, of course, if the pistol Roof received for his birthday is the same semiautomatic handgun that police say was used in the Charleston church shooting. If Roof owned guns he acquired prior to his felony charge, he would have been allowed to hang onto them.

In a speech today, President  Obama criticized the laws that make guns easily available in South Carolina. “Once again, innocent people were killed because someone who wanted to inflict harm had no trouble getting their hands on a gun,” he said.

The National Rifle Association recently changed its mind on universal background checks, coming out against them. “Background checks will never be ‘universal’ because criminals will never submit to them,” NRA Executive Vice President Wayne LaPierre said in 2013.

Yet according to a Johns Hopkins poll released that same year, 74 percent of NRA members and 89 percent of Americans support the policy.

This post has been updated with more details about background check laws.