From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3deb0e7ecee0ee8a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!q40g2000prg.googlegroups.com!not-for-mail From: deadlyhead Newsgroups: comp.lang.ada Subject: Re: Access to C_float wipes out float value Date: Thu, 19 Aug 2010 19:12:13 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 216.57.220.9 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1282270333 1054 127.0.0.1 (20 Aug 2010 02:12:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 20 Aug 2010 02:12:13 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q40g2000prg.googlegroups.com; posting-host=216.57.220.9; posting-account=snJuNwoAAABnc8T9lYkBlDQrDdSjOjG2 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13525 Date: 2010-08-19T19:12:13-07:00 List-Id: On Aug 19, 7:09=A0pm, Yannick Duch=EAne (Hibou57) wrote: > Le Fri, 20 Aug 2010 03:40:18 +0200, deadlyhead a = =A0 > =E9crit: > > > > > void* > > do_something (int get_float) > > { > > > =A0 int* =A0 i; > > =A0 float* f; > > > =A0 int in =3D 12345; // <<< local > > =A0 float fl =3D 9876.54321; // idem > > > =A0 f =3D &fl; // <<< reference to local > > =A0 i =3D ∈ // idem > > > =A0 if (!get_float) { > > =A0 =A0 printf ("Value of \"*i\" is %d\n", *i); > > =A0 =A0 return i; // <<< return reference to local > > =A0 } else { > > =A0 =A0 printf ("Value of \"*f\" is %f\n", *f); > > =A0 =A0 return f; // idem > > =A0 } > > } > > Did you really want to return a reference to a local variable ? Are you = =A0 > sure ? Ah, thank you. I didn't even think of that.