The bug was described here: https://openxcom.org/forum/index.php/topic,10967.msg157865.html#msg157865 (https://openxcom.org/forum/index.php/topic,10967.msg157865.html#msg157865)
Suggested fix was on the very next comment.
(https://openxcom.org/forum/index.php?action=dlattach;topic=10967.0;attach=60683;image)
When you're targeting a unit, which stands on a high terrain level, sometimes you get target voxel on the upper tile.
Tile *t = ... target->toTile() gives a pointer to that upper tile
getOverlappingUnit() gives a pointer to the unit which "pokes" to the upper tile
but then hasLOS = ... visible( bu, t ) uses that old upper tile, doesn't find a unit in it and returns false, thus incorrectly applying noLOSAccuracyPenalty.
Suggested solutions: either locally redefine Tile *t from found unit inside if (targetUnit) { ... } block, or change tile->getUnit() to tile->getOverlappingUnit() inside TileEngine::visible()
Savefile (XPZ) with the issue is attached here: https://openxcom.org/forum/index.php/topic,10967.msg157827.html#msg157827 (https://openxcom.org/forum/index.php/topic,10967.msg157827.html#msg157827)