Re: Is this valid C statement?

From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 09/27/04


Date: 27 Sep 2004 14:59:37 GMT

In <cj8pl7$6vd$1@oravannahka.helsinki.fi> Joona I Palaste <palaste@cc.helsinki.fi> writes:

>s.subbarayan <s_subbarayan@rediffmail.com> scribbled the following:
>> Dear all,
>> According to standards is this valid:
>
>> char TmpPtrWriteBuffer[1000];
>> void* PtrWriteBuffer =(void*) TmpPtrWriteBuffer;
>
>> I had a debate with my colleagues that anything cant be typecasted to
>> void* though the reverse is true.But they said this is valid.
>> I just can't agree with them with out a valid explaination.Can any C
>> standard experts clarify me this?
>
>You are right on this one. A pointer to anything can be assigned into a
>void *, even without a cast. ^^^^^^^^

You are wrong on this one. Pointers to functions cannot be converted
(either explicitly or implicitly) to pointers to void (and vice versa).
Undefined behaviour due to lack of specification in the standard.

Dan

-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
           Currently looking for a job in the European Union


Relevant Pages

  • Re: derangement: coding review request
    ... The obvious issue with my solution is that pointers are not exactly ... > Are you contending that the code doesn't work for some defined FAMSIZ < ... The same holds in the general setting for all rand() values between ... >>random numbers in your discussion with Dan Pop. ...
    (comp.lang.c)
  • Re: Swapping Bullshit
    ... Dan Pop wrote: ... > If you can do it with unsigned integer types, you can do it with all kinds ... >>pointers and indirecting through them. ... Please describe a situation where two variables share the same memory ...
    (comp.lang.c)
  • Re: Swapping Bullshit
    ... Dan Pop wrote: ... > If you can do it with unsigned integer types, you can do it with all kinds ... >>pointers and indirecting through them. ... Please describe a situation where two variables share the same memory ...
    (comp.lang.cpp)
  • Re: Typecasting in C
    ... >statements for debugging since there wasn't any debugger in those times. ... Without casting the pointers, those printf calls have *always* been ... Your main competition, gcc, does a better job than you do and this is the ... Dan Pop ...
    (comp.lang.c)
  • Re: Arithmetic expressions w. recursive descent parser?
    ... > The problem is that I cant get the implementation right with +,- in ... > I would appreciate any help, pointers, tips, on how to get the + and - ... This web page also contains Java source code. ... Prev by Date: ...
    (comp.compilers)