Or in any other type of container. They bug out. One day they just decide to not stack with other gold. Or not be counted, nor retrieved on the barter balance button, it says you have no money despite there being a nice stack of thousands of gold. It is possible to manually drag the gold to the barter inventory, though.
From what I can read on reddit, this is a known issue. Common fixes are stuff like dropping the money on the ground and pick it up again. Or splitting the stack to get the money out of that corrupted stack. I cant confirm any of those because I went for the fix of spending every ounce of gold, but havent had chance to check with a trader yet if my new stack of gold is uncorrupted.