# cat x.c #include <stdio.h> int main() { int addr; addr = __builtin_return_address (0); printf("%d\n", addr); return 0; } # /usr/gcc-3.4/bin/gcc -O x.c x.c: In function `main': x.c:8: warning: assignment makes integer from pointer without a cast /tmp/ccoJdxcc.o(.text+0x11): In function `main': : undefined reference to `retaddr' collect2: ld returned 1 exit status
Another related bug: [hjl@gnu-2 tmp]$ cat x.c #include <stdio.h> int main() { int addr [10]; addr [0] = (int) __builtin_return_address (0); printf("%d\n", addr [0]); return 0; } [hjl@gnu-2 tmp]$ gcc -c x.c -O x.c: In function `main': x.c:8: warning: cast from pointer to integer of different size /tmp/ccQZPp9G.s: Assembler messages: /tmp/ccQZPp9G.s:23: Error: Operand 2 of `st4' should be a general register
Richard's http://gcc.gnu.org/ml/gcc-patches/2003-08/msg00283.html should fix it. I'll wait till it is applied to the trunk and apply it to our gcc branches too (maybe without the removal of the no longer used virtual register to keep the changes smaller).