[Bug c++/58116] New: missed-optimization: const temporaries could be promoted to static
luto at mit dot edu
gcc-bugzilla@gcc.gnu.org
Sat Aug 10 00:02:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58116
Bug ID: 58116
Summary: missed-optimization: const temporaries could be
promoted to static
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: luto at mit dot edu
This code:
struct S
{
int a, b, c;
};
extern void callee(const S &s);
void test()
{
const S s{1,2,3};
callee(s);
callee((const S){1,2,3});
}
would be shorter and faster if both S instances were promoted to statics. This
would be correct because it's undefined behavior to modify a non-mutable member
of an object declared const in C++. (I'm not sure about C.)
More information about the Gcc-bugs
mailing list