diff --git a/tool/MasterDevice.cpp b/tool/MasterDevice.cpp
index 7ae2840498567853959a8506725641d2c623b007..e6508342178f14eef4890fa7579d0c680fff760f 100644
--- a/tool/MasterDevice.cpp
+++ b/tool/MasterDevice.cpp
@@ -85,7 +85,7 @@ void MasterDevice::open(Permissions perm)
         if (module_data.ioctl_version_magic != EC_IOCTL_VERSION_MAGIC) {
             stringstream err;
             err << "ioctl() version magic is differing: "
-                << deviceName << ": " << module_data.ioctl_version_magic
+                << deviceName.str() << ": " << module_data.ioctl_version_magic
                 << ", ethercat tool: " << EC_IOCTL_VERSION_MAGIC;
             throw MasterDeviceException(err);
         }