[Issue 23987] Copy construction should not disable implicit conversion
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 19 13:48:54 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23987
--- Comment #3 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to RazvanN from comment #2)
>
> void main()
> {
> immutable(S) s1 = S(2);
> immutable(S) s2 = s1;
> writeln(*s2.p);
> *s = 9;
> writeln(*s2.p);
> }
`p` is not a pointer so no need for the `*`. Sorry for the bogus test case.
Correct code:
```
int* s;
struct S
{
int p;
this(const ref S src)
{
s = &p;
}
}
void main()
{
immutable(S) s1 = S(2);
immutable(S) s2 = s1;
writeln(s2.p);
*s = 9;
writeln(s2.p);
}
```
--
More information about the Digitalmars-d-bugs
mailing list