9862 – [3.3/3.4 regression] spurious warnings with -W -finline-functions (original) (raw)

In the file <file.c> given below, the function might return with or without a value.

If compiling with -ansi -Wall -W -O3, the compiler warns about this, but also warns about the function having the same problem, which is not the case.

<file.c> extern int i; extern int f(void); extern int trigger(void);

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

int trigger(void) { if( i ) return; else return 1; } </file.c>

Release: 3.2.2

Environment: System: SunOS neuchatel 5.8 Generic_108528-17 sun4u sparc SUNW,Sun-Blade-100 Architecture: sun4

host: sparc-sun-solaris2.7 build: sparc-sun-solaris2.7 target: sparc-sun-solaris2.7 configured with: ./configure --prefix=/misc/ultra-sun-solaris2/gcc-3.2.2 --enable-threads=posix --disable-shared --disable-multilib

How-To-Repeat: gcc -ansi -Wall -W -O3 -c file.c

Comment 1 danielv 2003-02-26 13:56:00 UTC

Fix:

NOTE: This e-mail and any file attached therewith is intended only for the named recipient(s) above and contains information that is confidential and may be legally privileged and/or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this e-mail message.

NOTE: Ce courriel ainsi que tout fichier d'accompagnement est destiné à l'usage exclusif du destinataire(s) mentionné(s) ci-dessus et peut contenir de l'information confidentielle, privilegiée et/ou dispensée de divulgation aux termes des lois applicables. Si vous avez reçu ce message par erreur, ou s'il ne vous est pas destiné, veuillez le mentionner immédiatement à l'expéditeur et effacer ce courriel.

Comment 2 Wolfgang Bangerth 2003-02-26 17:31:46 UTC

State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. -O3 is actually needed.

Comment 3 Wolfgang Bangerth 2003-05-28 23:37:44 UTC

It's actually a regression:

g/x> gcc -c test.c -O3 -ansi -Wall -W test.c: In function trigger': test.c:13: warning: return' with no value, in function returning non-void test.c:15: warning: this function may return with or without a value

g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -c test.c -O3 -ansi -Wall -W test.c: In function trigger': test.c:13: warning: return' with no value, in function returning non-void test.c: In function f': test.c:9: warning: this function may return with or without a value test.c: In function trigger': test.c:15: warning: this function may return with or without a value

Comment 4 Steven Bosscher 2003-07-11 23:44:55 UTC

Wolfgang, is this one really target-specific? I'd be surprised...

Comment 5 Dara Hazeghi 2003-07-11 23:57:27 UTC

Nope. Confirmed as not target-specific (20030710). Happily reproduced on i686-linux.

Comment 6 Wolfgang Bangerth 2003-07-12 22:50:31 UTC

Steven: I only have x86 to check, so can't say whether something is target-specific :-) Why do you think I suggested it was?

W.

Comment 7 s.bosscher 2003-07-12 23:02:34 UTC

Subject: RE: [3.3/3.4 regression] spurious warnings with -W - O3

Why do you think I suggested it was?

I did not :-)

Can you assign it to me, I'll see if i can find out what is going on here (I suspect I know what is causing this).

Comment 8 Steven Bosscher 2003-07-13 00:00:56 UTC

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.

Comment 10 Drea Pinski 2003-07-13 20:01:31 UTC

Moving target to 3.3.2 based on email from Mark which states he is accepting only fixes for ice-on-valid-code and wrong-code patches for 3.3.1 now <http://gcc.gnu.org/ml/gcc- patches/2003-07/msg01319.html>.

Comment 15 Steven Bosscher 2003-09-06 14:45:06 UTC

Fixed