On Wednesday, 5 June 2024 at 18:31:12 UTC, Basile B. wrote:
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
```d
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
```d
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
assert(a == 0b); // what actually happens
On Wednesday, 5 June 2024 at 09:09:40 UTC, Kagamin wrote:
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
The only safe values for a `bool` are 0 (false) and 1 (true).
AFAIK that was fixed and now full 8-bit range is safe.
`cast(bool) someByte` is fine - that doesn't reinterpre
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
The only safe values for a `bool` are 0 (false) and 1 (true).
AFAIK that was fixed and now full 8-bit range is safe.
Basile B. kirjoitti 4.6.2024 klo 19.58:
I understand that the notion of `bool` doesn't exist on X86, hence what
will be used is rather an instruction that write on the lower 8 bits,
but with a 7 bits corruption.
Do I corrupt memory here or not ?
Is that a safety violation ?
Viewing a valid boo
On Wednesday, 5 June 2024 at 05:15:42 UTC, Olivier Pisano wrote:
This is technically not a memory corruption, because as
bool.sizeof < int.sizeof, you just write the low order byte of
an int you allocated on the stack.
It was not an int, it was a ushort. Anyway, what I wrote still
applies.
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
question in the header, code in the body, execute on a X86 or
X86_64 CPU
I understand that the notion of `bool` doesn't exist on X86,
hence what will be used is rather an instruction that write on
the lower 8 bits, but with a 7 bits c
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
you have violated the language's safety invariants.
ah mais non.
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
```d
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
assert(a == 0b); // what actually happens
assert(a == 0b1110); // what would be safe
}
```
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
question in the header, code in the body, execute on a X86 or
X86_64 CPU
```d
module test;
void setIt(ref bool b) @safe
{
b = false;
}
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
s
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
question in the header, code in the body, execute on a X86 or
X86_64 CPU
```d
module test;
void setIt(ref bool b) @safe
{
b = false;
}
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
s
question in the header, code in the body, execute on a X86 or
X86_64 CPU
```d
module test;
void setIt(ref bool b) @safe
{
b = false;
}
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
assert(a == 0b); // what actu
12 matches
Mail list logo