This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/24786] New: Missing warning on questionable use of parameter to initialize static


gcc only warns on blah1 on the following code:

const char *blah1() {
   char x = 7;
   return &x;
}

const char *blah2() {
   char x = 7;
   static const char *names[1] = { &x }; 
   return names[0];
}

returnlocal.cc: In function 'const char* blah1()':
returnlocal.cc:2: warning: address of local variable 'x' returned

Shouldn't it warn on blah2 as well?
Or is that asking too much?


-- 
           Summary: Missing warning on questionable use of parameter to
                    initialize static
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dank at kegel dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24786


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]