https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69971
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org --- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #0) > Calling __builtin_return_address with a large argument (say due to a coding > bug obscured by macros or template arguments) can result in resource > exhaustion by the compiler as it emits at least one instruction for each > level. It seems that for levels greater some threshold GCC could emit a > loop instead to avoid this problem (as unlikely as it may be). > > The following is an example run on powerpc64le where GCC emits a stream of > ld 9,0(9) instructions, one for each level: > > $ cat t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall > -Wextra -Wpedantic -o/dev/stdout t.c | grep "ld 9" | wc -l > void* foo (void) > { > void *p = __builtin_return_address (1024); > return p; > } > t.c: In function ‘foo’: > t.c:3:11: warning: calling ‘__builtin_return_address’ with a nonzero > argument is unsafe [-Wframe-address] > void *p = __builtin_return_address (1024); > ^ > 1027 Isn't this why the -Wframe-address warning you're getting exists in the first place?