---
void main()
{
const(int)* a;
void* b;
auto c = true ? a : b;
pragma(msg, typeof(c)); // const(int)*
}
---
typeof(c) should be const(void)*. This affects std.traits.CommonType.
Comment #1 by razvan.nitu1305 — 2022-10-28T09:19:06Z
This has now been fixed. It seems indeed that the common type is void*, however the initial example fails at line 5: test.d(5): Error: cannot implicitly convert expression `a` of type `const(int)*` to `void*`, which is correct.
Comment #2 by ag0aep6g — 2022-10-29T06:00:51Z
(In reply to RazvanN from comment #1)
> This has now been fixed. It seems indeed that the common type is void*,
> however the initial example fails at line 5: test.d(5): Error: cannot
> implicitly convert expression `a` of type `const(int)*` to `void*`, which is
> correct.
This has not been fixed. The common type is `const(void)*`, not `void*`. Reopening.
Comment #3 by apz28 — 2022-10-29T13:26:46Z
Try different order & type -> still problem
void main()
{
const(int)* a;
const(void)* b;
auto c = true ? b : a;
pragma(msg, typeof(c));
}
onlineapp.d(5): Error: cannot implicitly convert expression `b` of type `const(void)*` to `const(int)*`
const(int)*
Comment #4 by robert.schadek — 2024-12-13T18:46:30Z