Index: uspace/lib/cpp/include/impl/complex.hpp
===================================================================
--- uspace/lib/cpp/include/impl/complex.hpp	(revision 25709c348a700a1d32d609841cc75c1f82804174)
+++ uspace/lib/cpp/include/impl/complex.hpp	(revision 937de9810b2f5c105d43639ca94814c74374cf0a)
@@ -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_);
 
