This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/34048] [4.3 Regression]: Revision 130040 miscompiles 450.soplex
- From: "bonzini at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2007 07:16:18 -0000
- Subject: [Bug tree-optimization/34048] [4.3 Regression]: Revision 130040 miscompiles 450.soplex
- References: <bug-34048-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #14 from bonzini at gnu dot org 2007-11-11 07:16 -------
It could also be possible to do something like this to avoid default
construction.
@@ -46,8 +46,8 @@ namespace soplex
class UnitVector : public SVector
{
private:
- Element themem; ///< memory for 1st sparse vector entry (size)
- Element themem1; ///< memory for 2nd sparse vector entry (idx,1.0)
+ char themem[sizeof(Element[2])]; ///< memory for 1st sparse vector entry
(size)
+ /*Element themem1;*/ ///< memory for 2nd sparse vector entry (idx,1.0)
public:
/// returns value = 1
@@ -62,23 +62,22 @@ public:
/// construct \c i 'th unit vector.
UnitVector(int i = 0)
- : SVector(2, &themem)
+ : SVector(2, reinterpret_cast<Element *> (themem))
{
- add(i, 1.0);
+ new(themem[0]) Element (); new (themem[sizeof (Element)]) Element ();
add(i, 1.0);
}
/// copy constructor
UnitVector(const UnitVector& rhs)
- : SVector(2, &themem)
- , themem (rhs.themem)
- , themem1(rhs.themem1)
- {}
+ : SVector(2, reinterpret_cast<Element *> (themem))
+ { new(themem[0]) Element (reinterpret_cast<Element *> (rhs.themem[0]));
+ new(themem[sizeof (Element)]) Element (reinterpret_cast<Element *>
(rhs.themem[sizeof (Element)])); }
/// assignment
UnitVector& operator=(const UnitVector& rhs)
{
if ( this != &rhs )
- themem1 = rhs.themem1;
+ new(themem[sizeof (Element)]) Element (reinterpret_cast<Element *>
(rhs.themem[sizeof (Element)]));
return *this;
}
Not the cleanest possible code, but I doubt SPEC will like to introduce a
src.alt that makes previous reports not comparable with the new ones.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34048