March 29, 2020 Re: Spec on casting to integer with smaller range than value | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan | On Saturday, 28 March 2020 at 19:11:04 UTC, Johan wrote:
> On Saturday, 28 March 2020 at 15:23:19 UTC, Stefan Koch wrote:
>>
>> cast (ubyte)x is the same as = ((cast(uint)x) & 0xff)
>
> Where does the spec say that?
>
It's a consequence of the int promotion rule D adheres to.
|
March 29, 2020 Re: Spec on casting to integer with smaller range than value | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On 28.03.20 16:33, kinke wrote:
> that should probably be explicitly mentioned as undefined behavior, to account for the observed LLVM/gcc behavior.
It can't be full-blown UB as such a cast works in @safe code.
|
Copyright © 1999-2021 by the D Language Foundation