Quote from Trading4Alpha:
The IRS language does not say anything about "different securities." It refers to "the same or substantially identical" securities for exactly this reason. Rather than test for the equivalence of stock symbols, the IRS looks at so-called "constructive sales" that remove one's risk of loss in the security (including the use of futures or options positions). If the investor, the IRS, and the tax court consider long SH to be "substantially identical" to shorting SPY or that buying SH removes ones exposure to loss in SPY, then the IRS will win.