Index: uspace/lib/cpp/include/impl/complex.hpp
===================================================================
--- uspace/lib/cpp/include/impl/complex.hpp	(revision 8794d1676282d452785f48495466bc39e9c558c4)
+++ uspace/lib/cpp/include/impl/complex.hpp	(revision 9ab40261c0ea59e9be198f9c17934880512711a1)
@@ -31,4 +31,5 @@
 
 #include <iosfwd>
+#include <sstream>
 
 namespace std
@@ -51,5 +52,5 @@
             template<class U>
             constexpr complex(const complex<U>& other)
-                : real_(other.real_), imag_(other.imag_)
+                : real_(other.real()), imag_(other.imag())
             { /* DUMMY BODY */ }
 
@@ -150,6 +151,7 @@
             complex& operator*=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
-                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+                imag_ = old_real * rhs.imag_ + imag_ * rhs.real_;
 
                 return *this;
@@ -159,7 +161,8 @@
             complex& operator/=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
-                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                imag_ = (imag_ * rhs.real_ - old_real * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
 
@@ -189,5 +192,5 @@
             template<class U>
             constexpr complex(const complex<U>& other)
-                : real_(other.real_), imag_(other.imag_)
+                : real_(other.real()), imag_(other.imag())
             { /* DUMMY BODY */ }
 
@@ -288,6 +291,7 @@
             complex& operator*=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
-                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+                imag_ = old_real * rhs.imag_ + imag_ * rhs.real_;
 
                 return *this;
@@ -297,7 +301,8 @@
             complex& operator/=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
-                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                imag_ = (imag_ * rhs.real_ - old_real * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
 
@@ -327,5 +332,5 @@
             template<class U>
             constexpr complex(const complex<U>& other)
-                : real_(other.real_), imag_(other.imag_)
+                : real_(other.real()), imag_(other.imag())
             { /* DUMMY BODY */ }
 
@@ -426,6 +431,7 @@
             complex& operator*=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
-                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+                imag_ = old_real * rhs.imag_ + imag_ * rhs.real_;
 
                 return *this;
@@ -435,7 +441,8 @@
             complex& operator/=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
-                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                imag_ = (imag_ * rhs.real_ - old_real * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
 
@@ -465,5 +472,5 @@
             template<class U>
             constexpr complex(const complex<U>& other)
-                : real_(other.real_), imag_(other.imag_)
+                : real_(other.real()), imag_(other.imag())
             { /* DUMMY BODY */ }
 
@@ -564,6 +571,7 @@
             complex& operator*=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
-                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+                imag_ = old_real * rhs.imag_ + imag_ * rhs.real_;
 
                 return *this;
@@ -573,7 +581,8 @@
             complex& operator/=(const complex<U>& rhs)
             {
+                auto old_real = real_;
                 real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
-                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                imag_ = (imag_ * rhs.real_ - old_real* rhs.imag_)
                       / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
 
