Getting action on your favorite D issues
Avrina
avrina12309412342 at gmail.com
Sat Jun 6 18:18:14 UTC 2020
On Saturday, 6 June 2020 at 15:36:07 UTC, Patrick Schluter wrote:
> On Saturday, 6 June 2020 at 14:34:11 UTC, Avrina wrote:
>> On Saturday, 6 June 2020 at 10:09:07 UTC, Patrick Schluter
>> wrote:
>>> On Friday, 5 June 2020 at 23:53:28 UTC, H. S. Teoh wrote:
>>>> Output:
>>>> -----------------
>>>> dead
>>>> -----------------
>>>>
>>>> Truly, DMD's backend is in the bright future of strange and
>>>> wonderful quantum effects, whereas LDC is clearly still
>>>> stuck in the antiquated classical past. ;-)
>>>>
>>> Sorry, but undefined behaviour is undefined behaviour. The
>>> dmd code generator is not at fault here.
>>
>> With statements like this I always feel like people don't
>> understand what "undefined behavior" means.
>>
>> All the void initializer does is not initialize the memory of
>> the bool. DMD is testing more than a single bit for a type
>> that is only a single bit, it flip flops between testing a
>> byte and testing a bit. That is most definitely a bug in the
>> DMD backend.
>
> Then it is also a bug in llvm and gcc as they generate the code
> under exactly the same assumption that a bool is 1 or 0 (and
> that in C, C++ and D).
> Only in contexts where there is int promotion is all the word
> checked.
No, that's why LDC doesn't have the same issue. D is suppose to
be better than C and C++, so saying its broken in C and C++ so D
should be broken too isn't a very convincing argument.
The issue is that DMD isn't consistent. Like I said before, it
flip flops between checking a single bit and 8 bits.
> This has nothing to do with the D frontend, #pure or whatnot.
> It's a pure backend code generation assumption.
> If the frontend violates that assumption, it is an issue of the
> frontend.
Which is why I said its an issue with the backend.
>>
>> Just to bring up an old debate, this has been argued to not be
>> a bug and is defined behavior and *will not* be changed.
>>
>> void foo(bool);
>> void foo(byte);
>>
>> foo(0); // calls bool
>> foo(1); // calls bool
>> foo(2); // calls byte
>
> This has nothing to do with the issue at hand.
> This it's a technical choice. It might be surprising, it is
> very likely a wrong choice, but it is not violation of the
> assumption of the backend (even if it a violation of the
> programmer).
I know it doesn't. The point was that book is treated as a 1-bit
integer, and DMDs backend treats it like a byte (sometimes).
More information about the Digitalmars-d
mailing list