[Bug c/35926] New: Pushing / Poping ebx without using it.
The following code produces a push and pop of ebx without using it inside: typedef struct toto_s *toto_t; toto_t add (toto_t a, toto_t b) { int64_t tmp = (int64_t)(intptr_t)a + ((int64_t)(intptr_t)b~1L); return (toto_t)(intptr_t) tmp; } Here is the output of the compiler: gcc version 4.3.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-O3' '-S' '-fomit-frame-pointer' '-save-temps' '-mtune=generic' /usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.0/cc1 -E -quiet -v immediate.c -mtune=generic -fomit-frame-pointer -O3 -fpch-preprocess -o immediate.i ignoring nonexistent directory /usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../i686-pc-linux-gnu/include #include ... search starts here: #include ... search starts here: /usr/local/include /usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/include /usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-O3' '-S' '-fomit-frame-pointer' '-save-temps' '-mtune=generic' /usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.0/cc1 -fpreprocessed immediate.i -quiet -dumpbase immediate.c -mtune=generic -auxbase immediate -O3 -version -fomit-frame-pointer -o immediate.s GNU C (GCC) version 4.3.0 (i686-pc-linux-gnu) compiled by GNU C version 4.3.0, GMP version 4.2.2, MPFR version 2.3.1. warning: GMP header version 4.2.2 differs from library version 4.1.4. GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128998 Compiler executable checksum: 6f004a95f08b214d06bfab9d0128e657 COMPILER_PATH=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.0/:/usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.0/:/usr/local/libexec/gcc/i686-pc-linux-gnu/:/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/:/usr/local/lib/gcc/i686-pc-linux-gnu/ LIBRARY_PATH=/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/:/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-O3' '-S' '-fomit-frame-pointer' '-save-temps' '-mtune=generic' [EMAIL PROTECTED] to-do]$ cat immediate.s .file immediate.c .text .p2align 4,,15 .globl add .type add, @function add: pushl %ebx movl12(%esp), %eax movl8(%esp), %ecx popl%ebx andl$-2, %eax addl%ecx, %eax ret .size add, .-add .ident GCC: (GNU) 4.3.0 .section.note.GNU-stack,,@progbits I can reproduce this problem for GCC 4.1.2 and GCC 4.2.2 too. -- Summary: Pushing / Poping ebx without using it. Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ppelissi at caramail dot com 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=35926
[Bug c/35926] Pushing / Poping ebx without using it.
--- Comment #1 from ppelissi at caramail dot com 2008-04-13 17:49 --- Created an attachment (id=15473) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15473action=view) preprocessed sources -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35926
[Bug c/23076] New: GNU C extension / attribute destructor + static : invalid storage class for function
The follwing program: #include stdio.h #define LOG FILE *log_file; int f2 (int x) { #ifdef LOG static long toto = 0; static const char *fname = __func__; static void __attribute__ ((destructor)) f (void) { fprintf (log_file, %s: toto=%ld\n, fname, toto); } toto += x; #endif return 42; } int main () { log_file = fopen (toto.log, w); f2 (3); return 0; } failed to compile with GCC 4.0.0 and GCC 4.0.1: morpork tmp 69 % /localdisk/gcc-4.0.1/bin/gcc tgcc.c tgcc.c: In function 'f2': tgcc.c:12: error: invalid storage class for function 'f' morpork tmp 68 % /localdisk/gcc-4.0.1/bin/gcc --version gcc (GCC) 4.0.1 Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. whereas it works perfectly with GCC 3.2.x, 3.3.x and GCC 3.4.x. -- Summary: GNU C extension / attribute destructor + static : invalid storage class for function Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ppelissi at caramail dot com 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=23076
[Bug c/19972] New: Return Local function pointer
When returning local function pointer, it doesn't produce any warnings. For example: int *h() { int z; return z; } int (*apply (int (*f) (const void *, const void *), void *a))(const void *) { int zozo(const void * b) { return f(a,b); }; return zozo; } Compile with -O2 -Wall, it produces a warning for h: ttt.c: In function 'h': ttt.c:17: warning: function returns address of local variable But not for `apply' (and it produces invalid code, which is normal). GCC Version: Using built-in specs. Configured with: ../configure --prefix=/global/morpork/gcc-4.0-20050130 Thread model: posix gcc version 4.0.0 20050130 (experimental) -- Summary: Return Local function pointer Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ppelissi at caramail dot com 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=19972