Package: gcc-4.8 Version: 4.8.2-11 Severity: normal Attached is a small C program. It just takes the address of a label, and subtracts the address of the function, to get the "size".
The problem is not directly related with that, though - the printf() output is wrong. When compiled with "-g -Wall" the output is as expected: $1 = 0x40 Continuing. 64 But with "-g -Wall -Os" I get $1 = 0x22 Continuing. -317 so the information returned from the function is ok (gets smaller with -Os), but the value used for printf() is wrong. -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.11-2-amd64 (SMP w/4 CPU cores) Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages gcc-4.8 depends on: ii binutils 2.24-2 ii cpp-4.8 4.8.2-11 ii gcc-4.8-base 4.8.2-11 ii libc6 2.17-97 ii libcloog-isl4 0.18.1-3 ii libgcc-4.8-dev 4.8.2-11 ii libgmp10 2:5.1.3+dfsg-1 ii libisl10 0.12.1-2 ii libmpc3 1.0.1-1 ii libmpfr4 3.1.2-1 ii zlib1g 1:1.2.8.dfsg-1 Versions of packages gcc-4.8 recommends: ii libc6-dev 2.17-97 Versions of packages gcc-4.8 suggests: ii binutils [binutils-gold] 2.24-2 ii gcc-4.8-doc 4.8.2-2 pn gcc-4.8-locales <none> ii gcc-4.8-multilib 4.8.2-11 pn libasan0-dbg <none> pn libatomic1-dbg <none> pn libbacktrace1-dbg <none> pn libgcc1-dbg <none> pn libgomp1-dbg <none> pn libitm1-dbg <none> pn libquadmath0-dbg <none> pn libtsan0-dbg <none>
#include <stdio.h> #include <unistd.h> #include <stdlib.h> int f(int a) { int i; if (!a) return (long)&&j - (long)f; for(i=0; i<100; i++) if (i * i < a) break; j: return i; } int main(void) { { char stg[256]; sprintf(stg, "gdb -q -p %d -ex 'print f(0)' -ex c &", getpid()); system(stg); } sleep(2); printf("%d\n", f(0)); return f(1); }