imatix / gsl

iMatix GSL code generator
http://www.imatix.com
GNU General Public License v3.0
539 stars 107 forks source link

get_{day,month}_abbrev return address of stack-local #157

Open jrtc27 opened 6 years ago

jrtc27 commented 6 years ago

I noticed the following warnings when compiling gsl:

sfllang.c: In function 'get_day_abbrev':
sfllang.c:611:13: warning: function may return address of local variable [-Wreturn-local-addr]
     return (handle_accents (abbrev));
            ~^~~~~~~~~~~~~~~~~~~~~~~~
sfllang.c:603:9: note: declared here
         abbrev [4];
         ^~~~~~
sfllang.c: In function 'get_month_abbrev':
sfllang.c:653:13: warning: function may return address of local variable [-Wreturn-local-addr]
     return (handle_accents (abbrev));
            ~^~~~~~~~~~~~~~~~~~~~~~~~
sfllang.c:644:9: note: declared here
         abbrev [4];
         ^~~~~~

Indeed, both warnings are correct, since handle_accents just returns the buffer it's given. Thankfully, nothing in gsl itself is using these functions, but it's just a matter of time until one of them gets used. Please fix this.

bluca commented 6 years ago

Fixed in https://github.com/zeromq/gsl/pull/17 (note that this repo is in read-only mode now)