Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!mit.eternal-september.org!.POSTED!not-for-mail From: Richard Newsgroups: comp.lang.c Subject: Re: pass by address Date: Mon, 05 May 2014 12:01:46 +0200 Organization: http://www.ieee.org/ Lines: 61 Message-ID: <87ha54v911.fsf@gmail.com> References: <1phbm9t64tdkhq9pq5ng42v15s44tr01e0@4ax.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mit.eternal-september.org; posting-host="429d8c2c78b8d1bf0d1dfc93e35d17bc"; logging-data="5657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bidxWYmXTOpu3KoL6NeT8bYnMob7+N/I=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:qBJAhdWO/vraNoYYFRbAD2jveOU= sha1:bwERcqu5ArHDgq6t1Ae6DBQZw/g= Xref: csiph.com comp.lang.c:44035 Barry Schwarz writes: > On Sun, 4 May 2014 15:06:07 -0400, "Bill Cunningham" > wrote: > >> >>"Keith Thompson" wrote in message >>news:lnr44aj596.fsf@nuthaus.mib.org... >>> Tonton Th writes: >>>> On 2014-05-04, Barry Schwarz wrote: >>>>>>#include >>>>>> >>>>>>int main() >>>>>>{ >>>>>> int a = 15; >>>>>> int *p; >>>>>> p = &a; >>>>>> printf("%p\n", &p); >>>>> >>>>> Undefined behavior #1. >>>>> >>>>>> printf("%p\n", p); >>>>> >>>>> Undefined behavior #2. >>>>> >>>>>> printf("%d\n", *p); >>>>>>} >>>> >>>> I don't understand where in the undefined behaviour. Not so usable >>>> values printed, yes, but &p and p are pointers, so %p can print their >>>> values, no ? >>>> >>>> Maybe because p and &p are not 'void *' pointers... >>> >>> That's exactly it. "%p" requires an argument of type void*, not of any >>> arbitrary pointer type. In practice, most implementations use the same >>> representation and argument passing convention for all pointer types, so >>> it's likely to work, but for well-defined behavior you need to cast the >>> arguments to void*. >> >> Well I learned something today new. I'll keep that in mind. What would > > No you didn't. And you probably won't. This is the same advice you > were given as recently as August 20, 2012. Maybe you should consider So you remember everything you were told two years ago? Amazing! > saving some of the responses to your messages and rereading them to > reinforce the lessons they provide. Are you for real? You ALSO don't realise you're being trolled?!?!?! Life can't be fun when so easily made to jump for every treat. > >>be the best way to take careof that in your opinion? Cast a (void *). These >>are the little things that you need to know so when you get into big >>programs could cause real problems. -- "Avoid hyperbole at all costs, its the most destructive argument on the planet" - Mark McIntyre in comp.lang.c