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/39430] New: GCC does not put 'const auto' structure on the stack


This code creates an 'activation record' structure for each active
call to the function:

  struct frame { char const *name; int line; };
  extern void trace(struct frame const *);
  int f(int n) {
    const struct frame v = { __FUNCTION__, __LINE__ };
    trace(&v);
    return n ? n*f(n-1) : 1;
  }

These should be distinct, i.e. their addresses are distinct to
any observer.  But GCC evaluates &v to refer to one instance in
static storage.  Surely the standard doesn't allow an implementation
to do this.  It doesn't happen if 'v' is not marked 'const'.


-- 
           Summary: GCC does not put 'const auto' structure on the stack
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: algrant at acm dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39430


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