The tax office has recently issued a draft ruling on situations where someone has made a capital gain and alos has some shares trading below their cost base. The taxpayer sells the shares to generate a capital loss but repurchases the shares because he/she believes they will grow in the future.
The tax office draft indicates that they will disallow the offset of the loss against the gain because the share sale was merely an arrangement to generate a tax benefit and can be therefore denied inter Part IVA of the tax Act.
This has been a common practice for decades.
Please note that this is only a draft published for public comment, but does give an insight of the ATO thinking.
The full ruling which contains examples can be found here