Bugzilla – Bug 129945
returning pointer to local variable
Last modified: 2005-10-21 13:09:06 UTC
I just tried to compile package dvgt-3.51L3-1044 with the Intel C compiler It said options.c(112): warning #1251: returning pointer to local variable The source code is return (char *) &s; I've checked the code and this one is most unusual. The code is certainly wrong. Suggest change return type to void.
This should do the job return (Char*)&s[0]; at least for gcc 4.1. Remaining warnings g31:src # grep warning: /.build.log | wc -l 332
>This should do the job I've had a think about it, and I don't think so. Adding the trailing [ 0], as far as I know, doesn't help. s is a local variable on the stack. Taking it's address as return value is surely a mistake, isn't it ? I think my original advice still stands. >332 remaining warnings. Good job I'm only looking at the serious ones ;->
Hmmm ... gcc 4.1 reports the same error without '[0]' but no one with the choosen element. It seems that the gcc reports the address of the String object specified to stringcopy() .. what does the Intel compiler do in this case? Otherwise I could also use a pointer intstead of using an array.