If the AP shot has no chance of piercing the enemy armour, then HE will be fired to preserve the AP ammo loadout (it may well break the track). This is not a "bug".
Maybe you right but it occurs even when a low armored unit is aimed (say frontal armor 1 or 2) and the firing unit use shell with warhead of 3 or more...