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/9862] [3.3/3.4 regression] spurious warnings with -W -O3


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From steven at gcc dot gnu dot org  2003-07-13 00:00 -------
This PR is a result of defering functions.  The problem is that in c-decl we
assume that two global variables, current_function_retunrs_value and
current_function_returns_null, are reset for the current function, which is not
true if the function we're expanding is not the function we just parsed.  So for
this test case:

extern int i;
 
static int f(void) {
  if( i ) return 0; else return 1;
}
 
static int trigger(void) {
  if( i ) return; else return 1;
}

the current_function_returns_{value, null} variables have the values they should
have for "trigger" when we expand "f", and we get the warning:

if (extra_warnings
      && current_function_returns_value
      && current_function_returns_null)
    warning ("this function may return with or without a value");

If the two functions in the test case are switched (trigger before f) we get no
warnings at all.

With the rtl inliner we always expanded and then deferred.  With the tree
inliner this is not the case.

To check, I tried GCC 3.2 and indeed it shows the same bug.  Contrary to the
comments in the audit trail, -O3 is not necessary.  Just -O -finline-functions
will trigger the same problem.

I'll work on a fix for this.


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