Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #44035

Re: pass by address

From Richard <rgrdev_@gmail.com>
Newsgroups comp.lang.c
Subject Re: pass by address
Date 2014-05-05 12:01 +0200
Organization http://www.ieee.org/
Message-ID <87ha54v911.fsf@gmail.com> (permalink)
References (8 earlier) <1phbm9t64tdkhq9pq5ng42v15s44tr01e0@4ax.com> <slrnlmbvg5.m4n.tth@hangartistique.cispeo.fr> <lnr44aj596.fsf@nuthaus.mib.org> <lk632v$uk1$1@dont-email.me> <l0gdm99ekljnqd8o6f771kr8afbjvlf8rh@4ax.com>

Show all headers | View raw


Barry Schwarz <schwarzb@dqel.com> writes:

> On Sun, 4 May 2014 15:06:07 -0400, "Bill Cunningham"
> <nospam@nspam.invalid> wrote:
>
>>
>>"Keith Thompson" <kst-u@mib.org> wrote in message 
>>news:lnr44aj596.fsf@nuthaus.mib.org...
>>> Tonton Th <tth@nowhere.invalid> writes:
>>>> On 2014-05-04, Barry Schwarz <schwarzb@dqel.com> wrote:
>>>>>>#include <stdio.h>
>>>>>>
>>>>>>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

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 16:53 -0400
  Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 17:03 -0400
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 17:20 -0400
  Re: pass by address Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-02 17:58 -0400
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 18:09 -0400
      Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-02 16:37 -0700
        Re: pass by address gazelle@shell.xmission.com (Kenny McCormack) - 2014-05-02 23:43 +0000
          Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 15:58 +0200
            Re: pass by address gazelle@shell.xmission.com (Kenny McCormack) - 2014-05-03 14:08 +0000
              Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-03 10:38 -0700
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 21:13 +0200
        Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-03 01:46 -0400
        Re: pass by address "Bill Cunningaham" <nospam@nspam.invalid> - 2014-05-03 11:22 -0400
          Re: pass by address James Kuyper <jameskuyper@verizon.net> - 2014-05-03 12:13 -0400
          Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-03 12:34 -0700
            Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 22:33 +0200
            Re: pass by address glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-05-03 21:21 +0000
              Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-04 00:08 -0400
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-03 21:52 -0700
                Re: pass by address Tonton Th <tth@nowhere.invalid> - 2014-05-04 08:44 +0000
                Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-04 01:51 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-04 15:06 -0400
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-04 15:35 -0700
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-05 12:01 +0200
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-05 11:46 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 14:18 -0400
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-05 11:55 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 15:20 -0400
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 15:23 -0400
                Re: pass by address Ken Brody <kenbrody@spamcop.net> - 2014-05-06 11:02 -0400
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-06 14:46 -0400
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-05 12:00 +0200
                Re: pass by address Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-05-05 14:50 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 23:13 -0400
                Re: pass by address "Osmium" <r124c4u102@comcast.net> - 2014-05-05 23:09 -0500
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-06 08:55 -0400
                Re: pass by address Ken Brody <kenbrody@spamcop.net> - 2014-05-06 11:16 -0400
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-06 18:13 +0200
                Re: pass by address Kaz Kylheku <kaz@kylheku.com> - 2014-05-04 21:06 +0000
                Re: pass by address Kaz Kylheku <kaz@kylheku.com> - 2014-05-04 23:50 +0000
                Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-04 12:36 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 14:21 -0400
                Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-04 01:29 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-04 15:09 -0400
        Re: pass by address "Bill Cunningaham" <nospam@nspam.invalid> - 2014-05-03 11:32 -0400
  Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-02 16:43 -0700
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-03 01:54 -0400
      Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 15:59 +0200
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-03 02:08 -0400
      Re: pass by address "Bill Cunningaham" <nospam@nspam.invalid> - 2014-05-03 11:46 -0400
    Re: pass by address Kaz Kylheku <kaz@kylheku.com> - 2014-05-03 21:43 +0000

csiph-web