Thread overview
int** should be compatible to void**?
Jan 22, 2014
Walter Bright
Jan 22, 2014
Kenji Hara
Jan 23, 2014
Ali Çehreli
Jan 23, 2014
Stanislav Blinov
Jan 23, 2014
Ali Çehreli
Jan 23, 2014
Jakob Ovrum
January 22, 2014
Hello, this is a Japanese programmer, katahiromz.

If TYPE1 was compatible to TYPE2, I think TYPE1* should be compatible to TYPE2*.

Why isn't int** type compatible to void** type?

What's your idea? Thanks.
January 22, 2014
On 1/22/2014 12:36 AM, Katayama Hirofumi MZ wrote:
> Hello, this is a Japanese programmer, katahiromz.
>
> If TYPE1 was compatible to TYPE2, I think TYPE1* should be compatible to TYPE2*.
>
> Why isn't int** type compatible to void** type?


While void is untyped data, void* is definitely typed data.
January 22, 2014
Because it is definitely unsafe.

void main()
{
    int n;
    int* pn = &n;
    int** ppn = &pn;

    void** ppv = ppn;   // if this is allowed...?

    double x;
    double* px = &x;

    // double* is implicitly convertible to void*
    *ppv = px;

    // Wow, now int** points the double* data!
    assert(*ppn is cast(void*)px);
}

Kenji Hara


2014/1/22 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>

> Hello, this is a Japanese programmer, katahiromz.
>
> If TYPE1 was compatible to TYPE2, I think TYPE1* should be compatible to TYPE2*.
>
> Why isn't int** type compatible to void** type?
>
> What's your idea? Thanks.
>


January 22, 2014
Oh, I see. Thanks, Kenji san.

On Wednesday, 22 January 2014 at 09:04:31 UTC, Kenji Hara wrote:
> Because it is definitely unsafe.
January 23, 2014
On 01/22/2014 01:25 AM, Katayama Hirofumi MZ wrote:

> Oh, I see. Thanks, Kenji san.

Going off topic, that answers a question of mine! :) I could not be sure whether Kenji san, Hara san, or even Hara-san would be correct when I wrote to a Japanese person.

Ali

P.S. Going even more off topic, that person did not respond to my email yet. ;)

January 23, 2014
On Thursday, 23 January 2014 at 19:00:45 UTC, Ali Çehreli wrote:

> P.S. Going even more off topic, that person did not respond to my email yet. ;)

Maybe you actually did get it wrong? :)
January 23, 2014
On Thursday, 23 January 2014 at 19:00:45 UTC, Ali Çehreli wrote:
> On 01/22/2014 01:25 AM, Katayama Hirofumi MZ wrote:
>
> > Oh, I see. Thanks, Kenji san.
>
> Going off topic, that answers a question of mine! :) I could not be sure whether Kenji san, Hara san, or even Hara-san would be correct when I wrote to a Japanese person.
>
> Ali

All three are equally correct. Whether to use first or last name is similar to the equivalent split in the anglosphere. Using a hyphen is overwhelmingly common but not required in any system of romanization.
January 23, 2014
On 01/23/2014 11:09 AM, Stanislav Blinov wrote:
> On Thursday, 23 January 2014 at 19:00:45 UTC, Ali Çehreli wrote:
>
>> P.S. Going even more off topic, that person did not respond to my
>> email yet. ;)
>
> Maybe you actually did get it wrong? :)

I hope not. :)

Ali