TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTIAN S. PEDERSEN
from: JAVIER KOHEN
date: 1997-07-29 18:33:00
subject: Conversion of pointer.

On 24-Jul-97, Christian S. Pedersen wrote to All about Conversion of 
inter..
 CSP> int* test()
 CSP> {
 CSP>     int i=5;
 CSP>     return &i;
 CSP> }
 CSP> Why do I get a "Suspicious pointer conversion"-warning ? The functions
 CSP> using this concept seems to work OK. Should I make them differently.
There's a problem there, though... you're returning a local var's
address, but right after the return, you'll be back out of i's scope, so
there's no more 5 there... you shoul make 5 static, or return by value
or reference (I'm not sure about this one) instead of by address.
Javier Kohen  [The_Crusher] http://jkohen.base.org
... Linux, the choice of a GNU generation.
-!- CrusherTag 0.3.2.
--- Terminate 4.00/Pro
---------------
* Origin: The King of The Ring (4:900/748.3)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.