public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Yevgeny Kliteynik <kliteyn-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
Cc: Linux RDMA <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] opensm: fixing compilation issues in some header files
Date: Wed, 02 Jun 2010 10:29:17 +0300	[thread overview]
Message-ID: <4C06084D.3070101@dev.mellanox.co.il> (raw)
In-Reply-To: <20100602010314.GZ28549@me>

On 02-Jun-10 4:03 AM, Sasha Khapyorsky wrote:
> On 00:18 Wed 02 Jun     , Yevgeny Kliteynik wrote:
>>>
>>> AFAIR (anytype *) to (void *) casting is not needed (doing implicitly)
>>> in C and this is already part of some basic standards.
>>
>> True, but the problem is not (anytype *) to (void *) casting.
>> It's the other way around: (void *) to (anytype *) casting.
>
> It is the same meaning. Otherwise it would be useless.

No, it's not.
Casting TO void* is not dangerous - void* is just a "place holder".
Casting FROM void* is more dangerous - it means your program would
actually be using this pointer's content.

Right now gcc allows you to do implicit casting in both ways, g++ doesn't.

Try compiling this code:

#include <stdlib.h>
int main()
{
         void * v = NULL;
         int * t = NULL;
         v = t;
         t = v;
         return 0;
}

try.cc:7: error: invalid conversion from 'void*' to 'int*'

Here are more details:

   http://www2.research.att.com/~bs/bs_faq2.html#void-ptr


-- Yevgeny
  
> Sasha
>

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-06-02  7:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-24 15:50 [PATCH] opensm: fixing compilation issues in some header files Yevgeny Kliteynik
     [not found] ` <4BAA34B2.9060808-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-06-01 11:58   ` Yevgeny Kliteynik
     [not found]     ` <4C04F5E7.8030904-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-06-01 19:22       ` Sasha Khapyorsky
2010-06-01 21:18         ` Yevgeny Kliteynik
     [not found]           ` <4C057940.1020106-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-06-02  1:03             ` Sasha Khapyorsky
2010-06-02  7:29               ` Yevgeny Kliteynik [this message]
     [not found]                 ` <4C06084D.3070101-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-06-02 15:18                   ` Sasha Khapyorsky
2010-06-02 15:30                     ` Hal Rosenstock
     [not found]                       ` <AANLkTinyMA8WyFPee755nelj9gxJKTP7mQChYlDkUF4J-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-06-02 16:05                         ` Sasha Khapyorsky
2010-06-02 16:28                         ` Roland Dreier
2010-06-01 19:23   ` Sasha Khapyorsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C06084D.3070101@dev.mellanox.co.il \
    --to=kliteyn-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox