3 ms·
> Also interesting: The issues here are: - if it's defined, then people will rely on it, which means UBSan can't report it as an error if it sees it. - IIRC
by astrange 4y ago
> Also interesting:
The issues here are:
- if it's defined, then people will rely on it, which means UBSan can't report it as an error if it sees it.
- IIRC x86 defines the overflow behavior differently for scalar and vector ints, so x86 compilers that want to do autovectorization would probably leave it undefined.
C's original sin here is that the numeric promotion rules are wrong ('unsigned short' should not promote to 'int'!) but as long as you can't fix that, you can't get rid of UB and still be performant.
- uecker 4y agoWhat is wrong with promoting unsigned short to int?