This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51392] Wrong code with -Os when __attribute__((__const__)) function returns structure
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 04 Dec 2011 15:50:40 +0000
- Subject: [Bug c++/51392] Wrong code with -Os when __attribute__((__const__)) function returns structure
- Auto-submitted: auto-generated
- References: <bug-51392-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51392
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-04 15:50:40 UTC ---
__attribute__((__const__))
Vector3f pie_SurfaceNormal3fv(Vector3f a, Vector3f b)
{
return Vector3f(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x);
}
I think it is illegal to use the const attribute when the C++ frontend
may elide the return value copy to being passed by invisible reference.
That way the middle-end sees a store to global memory which is a side-effect
that the const attribute does not allow (similar for pure btw.).
Note that the Vector3f() constructors are not const either but they are
both called from pie_SurfaceNormal3fv.