public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
@ 2011-12-20 21:36 jan.kratochvil at redhat dot com
  2011-12-21  9:18 ` [Bug c/51644] " burnus at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-12-20 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51644
           Summary: [4.7 Regression] va_list vs. warning: ‘noreturn’
                    function does return is not fixable
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jan.kratochvil@redhat.com


PASS: gcc (GCC) 4.6.3 20111220 (prerelease)
FAIL: gcc (GCC) 4.7.0 20111220 (experimental)

#include <stdarg.h>
extern __attribute__ ((__noreturn__)) void b (int s, va_list ap);
__attribute__ ((__noreturn__)) void a (int s, ...)
{
  va_list args;
  va_start (args, s);
  b (s, args);
  va_end (args);
}

-Wall -fexceptions

35.c:9:1: warning: ‘noreturn’ function does return [enabled by default]

It gets fixed by removing that "va_end" but I must not (suggested by Tom
Tromey):

ISO C99 7.15.1 
Each invocation of the va_start and va_copy macros shall be matched by a
corresponding invocation of the va_end macro in the same function.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
@ 2011-12-21  9:18 ` burnus at gcc dot gnu.org
  2011-12-21  9:52 ` [Bug middle-end/51644] " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-21  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org
   Target Milestone|---                         |4.7.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
  2011-12-21  9:18 ` [Bug c/51644] " burnus at gcc dot gnu.org
@ 2011-12-21  9:52 ` rguenth at gcc dot gnu.org
  2011-12-21  9:53 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-21  9:52 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-21
          Component|c                           |middle-end
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-21 09:48:11 UTC ---
We are gimplifying this to

a (int s)
{
  struct  args[1];

  try
    {
      __builtin_va_start (&args, 0);
      b (s, &args);
      __builtin_va_end (&args);
    }
  finally
    {
      args = {CLOBBER};
    }
}

So the cleanup returns normally when b throws.  The ehcleanup stuff does
not trigger at -O0.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
  2011-12-21  9:18 ` [Bug c/51644] " burnus at gcc dot gnu.org
  2011-12-21  9:52 ` [Bug middle-end/51644] " rguenth at gcc dot gnu.org
@ 2011-12-21  9:53 ` jakub at gcc dot gnu.org
  2011-12-21  9:54 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-21  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-21 09:51:45 UTC ---
Caused by r181172 aka TREE_CLOBBER_P.  The problem is that we have before
*.cfg:
  __builtin_va_start (&args, 0);
  b (s, &args);
  __builtin_va_end (&args);
  finally_tmp.0 = 1;
  <D.2917>:
  args = {CLOBBER};
  switch (finally_tmp.0) <default: <D.2921>, default: <D.2921>, case 1:
<D.2918>>
  <D.2918>:
  goto <D.2919>;
  <D.2919>:
  return;
  <D.2920>:
  finally_tmp.0 = 0;
  goto <D.2917>;
  <D.2921>:
  resx 1
and *.cfg pass obviously optimizes away anything after the noreturn call:
<bb 2>:
  __builtin_va_start (&args, 0);
  b (s, &args);
<L5>:
  return;
<L3>:
  finally_tmp.0 = 0;
  args = {CLOBBER};
  switch (finally_tmp.0) <default: <L4>, case 1: <L5>>
<L4>:
  resx 1
but the warn_function_return pass is immediately after that (and, this is -O0
anyway), so nothing optimizes the switch away into simple fall through into the
resx 1 block.  At -O and above we don't warn, because the *.eh pass before
*.cfg pass optimizes this.

So, IMHO to fix this, we need to do 2 things:
1) in decide_copy_try_finally reconsider
     if (!optimize)
    return ndests == 1;
   if finally contains only gimple_clobber_p stmts
2) estimate_num_insns should return 0 for gimple_clobber_p stmts


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
                   ` (2 preceding siblings ...)
  2011-12-21  9:53 ` jakub at gcc dot gnu.org
@ 2011-12-21  9:54 ` jakub at gcc dot gnu.org
  2011-12-21 11:41 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-21  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jakub at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
                   ` (3 preceding siblings ...)
  2011-12-21  9:54 ` jakub at gcc dot gnu.org
@ 2011-12-21 11:41 ` jakub at gcc dot gnu.org
  2011-12-21 15:00 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-21 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-21 11:38:39 UTC ---
Created attachment 26159
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26159
gcc47-pr51644.patch

Fix I'm going to bootstrap/regtest.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
                   ` (4 preceding siblings ...)
  2011-12-21 11:41 ` jakub at gcc dot gnu.org
@ 2011-12-21 15:00 ` jakub at gcc dot gnu.org
  2011-12-21 15:33 ` jakub at gcc dot gnu.org
  2011-12-21 15:33 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-21 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-21 14:51:38 UTC ---
Author: jakub
Date: Wed Dec 21 14:51:19 2011
New Revision: 182589

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182589
Log:
    PR middle-end/51644
    PR middle-end/51647
    * tree-eh.c (decide_copy_try_finally): At -O0, return true
    even when ndests is not 1, if there are only gimple_clobber_p
    (or debug) stmts in the finally sequence.
    * tree-inline.c (estimate_num_insns): Return 0 for gimple_clobber_p
    stmts.

    * gcc.dg/pr51644.c: New test.
    * g++.dg/warn/Wreturn-4.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wreturn-4.C
    trunk/gcc/testsuite/gcc.dg/pr51644.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-eh.c
    trunk/gcc/tree-inline.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
                   ` (6 preceding siblings ...)
  2011-12-21 15:33 ` jakub at gcc dot gnu.org
@ 2011-12-21 15:33 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-21 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-21 15:31:54 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/51644] [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable
  2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
                   ` (5 preceding siblings ...)
  2011-12-21 15:00 ` jakub at gcc dot gnu.org
@ 2011-12-21 15:33 ` jakub at gcc dot gnu.org
  2011-12-21 15:33 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-21 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-21 15:32:11 UTC ---
*** Bug 51647 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-21 15:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 21:36 [Bug c/51644] New: [4.7 Regression] va_list vs. warning: ‘noreturn’ function does return is not fixable jan.kratochvil at redhat dot com
2011-12-21  9:18 ` [Bug c/51644] " burnus at gcc dot gnu.org
2011-12-21  9:52 ` [Bug middle-end/51644] " rguenth at gcc dot gnu.org
2011-12-21  9:53 ` jakub at gcc dot gnu.org
2011-12-21  9:54 ` jakub at gcc dot gnu.org
2011-12-21 11:41 ` jakub at gcc dot gnu.org
2011-12-21 15:00 ` jakub at gcc dot gnu.org
2011-12-21 15:33 ` jakub at gcc dot gnu.org
2011-12-21 15:33 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).