This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/39430] New: GCC does not put 'const auto' structure on the stack
- From: "algrant at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Mar 2009 12:01:37 -0000
- Subject: [Bug c/39430] New: GCC does not put 'const auto' structure on the stack
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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