This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14903] New: tail call optimization does not work with char return type
- From: "cesarb at nitnet dot com dot br" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Apr 2004 02:36:37 -0000
- Subject: [Bug optimization/14903] New: tail call optimization does not work with char return type
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
(old bug but couldn't find on bugzilla, see
http://gcc.gnu.org/ml/gcc/2002-09/msg00632.html )
When compiling:
extern unsigned char f(void);
unsigned char g(void) { return f(); }
With:
gcc -W -Wall -Os -fomit-frame-pointer -save-temps -c
The result is:
g:
call f
movzbl %al, %eax
ret
Notice the superfluous zero extension (signed char has a sign extension
instead). Without it, the call would be optimized to a jmp.
This makes it harder to try to use tail-recursive functions as if they were
loops (where the loop goes through 3-4 functions with one or two of them looked
up on a table).
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.3 (Debian 20040401)
--
Summary: tail call optimization does not work with char return
type
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cesarb at nitnet dot com dot br
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14903