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)
|