This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/69971] New: repetitive code with __builtin_return_address with a large level


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]