diff --git a/compiler2/tcov2lcov.cc b/compiler2/tcov2lcov.cc
index 53258e742b05105d77d17e331d64f74e853399ba..448e4f2738ce832a33c6df00361dff17e86d24b4 100644
--- a/compiler2/tcov2lcov.cc
+++ b/compiler2/tcov2lcov.cc
@@ -336,13 +336,14 @@ int main(int argc, char *argv[])
   // Leave it relative.
   if (!input_dir) input_dir = ".";
   if (!output_file)	output_file = "output.info";
+  std::string xsd_file_str;
   if (!xsd_file) {
     const char *ttcn3_dir = getenv("TTCN3_DIR");
     if (!ttcn3_dir) {
       std::cerr << "$TTCN3_DIR environment variable is not set" << std::endl;
       param_error = true;
     } else {
-      std::string xsd_file_str = std::string(ttcn3_dir) + P_SEP + std::string("include") + P_SEP + std::string("tcov.xsd");
+      xsd_file_str = std::string(ttcn3_dir) + P_SEP + std::string("include") + P_SEP + std::string("tcov.xsd");
       xsd_file = xsd_file_str.c_str();
     }
   }