Correctly calculate attribute size for cast