[Bug c++/60517] New: warning/error for taking address of member of a temporary object
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 13 15:54:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517
Bug ID: 60517
Summary: warning/error for taking address of member of a
temporary object
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: manu at gcc dot gnu.org
class B {
public:
double x[2];
};
class A {
B b;
public:
B getB(void) { return b; }
};
double foo(A a) {
double * x = &(a.getB().x[0]);
return x[0];
}
In the code above, x is not pointing to anything useful. I am not sure how hard
would be to diagnose this, but it would be nice if it was possible. It would
have saved me a few hours of bug-hunting today.
More information about the Gcc-bugs
mailing list