This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/69971] New: repetitive code with __builtin_return_address with a large level
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 26 Feb 2016 04:15:59 +0000
- Subject: [Bug c/69971] New: repetitive code with __builtin_return_address with a large level
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69971
Bug ID: 69971
Summary: repetitive code with __builtin_return_address with a
large level
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
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