mattkretz / wg21-papers

my papers to WG21 — the C++ committee
5 stars 7 forks source link

result of ushort(~0) * ushort(~0), UB? #55

Closed mattkretz closed 7 years ago

mattkretz commented 7 years ago

Normally ushort(~ushort()) * ushort(~ushort()) is UB, because of the promotion to signed int. Do we want that behavior for datapar<unsigned short/char> too? I'm strongly against keeping this strange behavior.

mattkretz commented 7 years ago

Hmm, this probably needs no extra work/wording. Because ushort <op> ushort -> int but datapar<ushort> <op> datapar<ushort> -> datapar<ushort>. Since the former loses its unsigned property UB is expected. The latter stays unsigned, so it requires modulo arithmetic.