In the file <file.c> given below, the <trigger> 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 <f> 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
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.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. -O3 is actually needed.
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
Wolfgang, is this one really target-specific? I'd be surprised...
Nope. Confirmed as not target-specific (20030710). Happily reproduced on i686-linux.
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.
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).
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.
Patch pending in "http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01286.html"
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>.
Created attachment 4489 [details] Patch for Bug 9862
Created attachment 4490 [details] test cases
Subject: Bug 9862 CVSROOT: /cvs/gcc Module name: gcc Changes by: steven@gcc.gnu.org 2003-09-06 13:34:00 Modified files: gcc : ChangeLog c-decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: 20030906-1.c 20030906-2.c Log message: PR c/9862 * c-decl.c (c_expand_body_1): Move return warning from here... (finish_function): ...to here. * gcc.dg/20030906-1.c: New test. * gcc.dg/20030906-2.c: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.984&r2=2.985 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.442&r2=1.443 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3028&r2=1.3029 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030906-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030906-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 9862 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: steven@gcc.gnu.org 2003-09-06 14:44:34 Modified files: gcc : c-decl.c ChangeLog Log message: PR c/9862 * c-decl.c (c_expand_body): Move return warning from here... (finish_function): ...to here Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.356.2.13&r2=1.356.2.14 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.723&r2=1.16114.2.724
Fixed
Subject: Bug 9862 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_2-rhl8-branch Changes by: jakub@gcc.gnu.org 2003-10-01 12:30:43 Modified files: gcc : ChangeLog c-decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: 20030906-1.c 20030906-2.c Log message: 2003-09-06 Steven Bosscher <steven@gcc.gnu.org> PR c/9862 * c-decl.c (c_expand_body_1): Move return warning from here... (finish_function): ...to here. * gcc.dg/20030906-1.c: New test. * gcc.dg/20030906-2.c: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.13152.2.657.2.27.2.168&r2=1.13152.2.657.2.27.2.169 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.300.2.10.2.1.2.12&r2=1.300.2.10.2.1.2.13 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.1672.2.166.2.8.2.69&r2=1.1672.2.166.2.8.2.70 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030906-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.6.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030906-2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.6.1