cause decimal_v2 use int128_t, C++ compiler will do some optimized for it. But the DecimalV2 value is not ensured to be aligned, which will cause crash.
cause decimal_v2 use int128_t, C++ compiler will do some optimized for it. But the DecimalV2 value is not ensured to be aligned, which will cause crash.
But it's printing a const void* value. And I've seen some reinterpret_cast to DecimalV2Value, e.g.
2条答案
按热度按时间eit6fx6z1#
cause decimal_v2 use int128_t, C++ compiler will do some optimized for it. But the DecimalV2 value is not ensured to be aligned, which will cause crash.
jckbn6z72#
cause decimal_v2 use int128_t, C++ compiler will do some optimized for it. But the DecimalV2 value is not ensured to be aligned, which will cause crash.
But it's printing a
const void* value
.And I've seen some reinterpret_cast to DecimalV2Value, e.g.
incubator-doris/be/src/exec/tablet_sink.cpp
Lines 851 to 853 in eefad13
| | case TYPE_DECIMALV2: { |
| | DecimalV2Value dec_val(reinterpret_cast<const PackedInt128*>(slot)->value); |
| | if (dec_val.greater_than_scale(desc->type().scale)) { |
So it's wrong to do like this?