TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTIAN S. PEDERSEN
from: ERIK JAKOBSEN
date: 1997-07-26 01:27:00
subject: Conversion of pointer.

Hello Christian!
Replying to a message of Christian S. Pedersen to All:
 CSP> int* test()
 CSP> {
 CSP>     int i=5;
  This is an auto variabel... as soon as your are leaving test it doesn't 
exist any longer . And you pointer is pointing to the stack area, but to a no 
longer allocated memory, ...
anybody can write there, so what you are doing is very wrong 
(ie:unreliable/undefined)
  You could allocate memory on til heap with new,  you could parse a 
reference or a pointer as argument to test( ...)  
 CSP>     return &i;
   this warning could be turned off or typecast away  ... return (int*)
 CSP> }
 CSP> Why do I get a "Suspicious pointer conversion"-warning ? The
 CSP> functions using this concept seems to work OK. Should I make them
 CSP> differently.
 CSP> Christian...
 CSP> -!- GoldED
 CSP>  ! Origin: Brain Warning! Ethanol Overload. Common sence halted.
 CSP> (2:235/209.27)
 0   Erik!
             |-
             |\
--- FleetStreet 1.20.2 NR
---------------
* Origin: DataVisor BBS - TeamOS2 (2:238/52.136)

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™.