Originally posted by cardich
View Post
#pragma GCC diagnostic ignored "-Wreturn-local-addr"
Its not miss information. Compliers need to get more picky. Particular things that are currently warning need to be errors that programmer cannot disable. Yes return local address should be a error not a warning because there is no valid code that uses it.
The more common version of use local address in return.
Code:
int * f() { int a, *b; //declared at start of function a = 12; //defined to a value // lines of code b=&a; // some like above on some optional path. // lines of code return b; }
The one with return &a and it be local is directly is rare by CVE but it happened 4 times this year. Of course the function was a function that would only run if a error had happened in all 4 cases. So error followed by another error so general testing was not detecting goof.
Leave a comment: