public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/33826]  New: GCC generates wrong code for infinitely recursive functions
@ 2007-10-20  7:06 tbm at cyrius dot com
  2007-10-20 10:03 ` [Bug tree-optimization/33826] [4.1/4.2/4.3 Regression] " rguenth at gcc dot gnu dot org
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: tbm at cyrius dot com @ 2007-10-20  7:06 UTC (permalink / raw)
  To: gcc-bugs

[ forwarded from http://bugs.debian.org/445536 ]

From: Samuel Tardieu <sam@rfc1149.net>

% cat > t.c << EOF
void foo()
{ foo(); }
EOF

% gcc -O -S -o - -fomit-frame-pointer -Wall t.c
        .file   "t.c"
        .text
.globl foo
        .type   foo, @function
foo:
        rep ; ret
        .size   foo, .-foo
        .ident  "GCC: (GNU) 4.2.1 (Debian 4.2.1-5)"
        .section        .note.GNU-stack,"",@progbits

As far as I know, there are two acceptable behaviours for function foo():
  - loop indefinitely (if tail recursion is used)
  - overflow the stack (if tail recursion is not used)

As soon as -O is used on x86-32, GCC generates code that just returns
("rep ; ret").

Note that the bug is also present with the following Ada program:

procedure U is
begin
   U;
end U;

although the Ada front-end warns about a possibly infinite recursion. The
very same code gets generated.

This may be platform-specific and generates bogus code with any non-O0
optimization level.


-- 
           Summary: GCC generates wrong code for infinitely recursive
                    functions
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tbm at cyrius dot com
GCC target triplet: x86_64-linux-gnu


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


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

end of thread, other threads:[~2008-01-24 21:36 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-20  7:06 [Bug target/33826] New: GCC generates wrong code for infinitely recursive functions tbm at cyrius dot com
2007-10-20 10:03 ` [Bug tree-optimization/33826] [4.1/4.2/4.3 Regression] " rguenth at gcc dot gnu dot org
2007-11-05  2:51 ` mmitchel at gcc dot gnu dot org
2007-11-05 21:38 ` steven at gcc dot gnu dot org
2007-11-05 22:16 ` zadeck at naturalbridge dot com
2007-11-05 23:06 ` ebotcazou at gcc dot gnu dot org
2007-11-06 18:50 ` sam at rfc1149 dot net
2007-11-06 19:04 ` ebotcazou at gcc dot gnu dot org
2007-11-06 21:21 ` zadeck at naturalbridge dot com
2007-11-06 21:34 ` ebotcazou at gcc dot gnu dot org
2007-11-06 21:53 ` zadeck at naturalbridge dot com
2007-11-07 18:44 ` zadeck at naturalbridge dot com
2007-11-08  1:23 ` zadeck at naturalbridge dot com
2007-11-08  9:08 ` richard dot guenther at gmail dot com
2007-11-08 16:46 ` zadeck at gcc dot gnu dot org
2007-11-08 16:48 ` zadeck at naturalbridge dot com
2007-11-08 16:49 ` zadeck at naturalbridge dot com
2008-01-09 19:12 ` ghazi at gcc dot gnu dot org
2008-01-09 22:04 ` zadeck at naturalbridge dot com
2008-01-11  4:22 ` ghazi at gcc dot gnu dot org
2008-01-11 13:19 ` zadeck at naturalbridge dot com
2008-01-23 21:54 ` [Bug tree-optimization/33826] [4.1/4.2 " rguenth at gcc dot gnu dot org
2008-01-24 21:05 ` ghazi at gcc dot gnu dot org
2008-01-24 21:26 ` ghazi at gcc dot gnu dot org
2008-01-24 22:09 ` ghazi at gcc dot gnu dot 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).