One of many headache-causing quirks in our tax law is the rule concerning "wash sales" (not to be confused with "wash trades", which are illegal corporate transactions). The law was created to prevent people from being able to sell shares in a given stock or mutual fund at a loss then almost immediately buying them back.
Basically, the idea was to keep people from having their cake and eating it too, i.e., getting their capital loss tax write-off for the year but holding on to the stock or mutual fund as well. This is called a "wash sale" and you are not allowed to take the capital loss if you buy back the same stock or mutual fund within 30 days of the sale. Fair enough, but like many other things in life, this law has produced some unintended consequences.
The major drawback is its effect on traders, who constantly buy and sell the same stocks or mutual funds over and over again at various quantities and prices. In this case, the law gets so complicated that many accountants don't understand it or even recognize some wash sales when they see them. It even drives IRS employees crazy. Many traders have difficulty resolving which and how much of any losing trade can be written off as a capital loss. Yet another reason tax reform is so badly needed.