MinGW tweak: Constructs such as:

CharArray somevariable = "somestring"

...are not allowed. It seems like MSVC does not correctly check
accessibility for temporaries. Chapter 12.2 of ISO/IEC 14882:2003(E):

>  Even when the creation of the temporary object is avoided (12.8),
>  all the semantic restrictions must be respected as if the temporary
>  object was created. [Example: even if the copy constructor is not
>  called, all the semantic restrictions, such as accessibility
>  (clause 11), shall be satisfied. ]




git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3344 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/win/rfb_win32/MsgBox.h b/win/rfb_win32/MsgBox.h
index 5957139..918a909 100644
--- a/win/rfb_win32/MsgBox.h
+++ b/win/rfb_win32/MsgBox.h
@@ -48,7 +48,7 @@
       flags |= MB_TOPMOST | MB_SETFOREGROUND;
       int len = _tcslen(AppName.buf) + 1;
       if (msgType) len += _tcslen(msgType) + 3;
-      TCharArray title = new TCHAR[len];
+      TCharArray title(new TCHAR[len]);
       _tcscpy(title.buf, AppName.buf);
       if (msgType) {
         _tcscat(title.buf, _T(" : "));
diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx
index dd1c3b0..ff94451 100644
--- a/win/rfb_win32/RegConfig.cxx
+++ b/win/rfb_win32/RegConfig.cxx
@@ -57,9 +57,9 @@
   DWORD i = 0;
   try {
     while (1) {
-      TCharArray name = tstrDup(key.getValueName(i++));
+      TCharArray name(tstrDup(key.getValueName(i++)));
       if (!name.buf) break;
-      TCharArray value = key.getRepresentation(name.buf);
+      TCharArray value(key.getRepresentation(name.buf));
       if (!value.buf || !Configuration::setParam(CStr(name.buf), CStr(value.buf)))
         vlog.info("unable to process %s", CStr(name.buf));
     }
diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx
index 1a828ed..4f073f4 100644
--- a/win/rfb_win32/Registry.cxx
+++ b/win/rfb_win32/Registry.cxx
@@ -175,7 +175,7 @@
 }
 
 void RegKey::getBinary(const TCHAR* valname, void** data, int* length) const {
-  TCharArray hex = getRepresentation(valname);
+  TCharArray hex(getRepresentation(valname));
   if (!rdr::HexInStream::hexStrToBin(CStr(hex.buf), (char**)data, length))
     throw rdr::Exception("getBinary failed");
 }
@@ -193,7 +193,7 @@
 }
 
 int RegKey::getInt(const TCHAR* valname) const {
-  TCharArray tmp = getRepresentation(valname);
+  TCharArray tmp(getRepresentation(valname));
   return _ttoi(tmp.buf);
 }
 int RegKey::getInt(const TCHAR* valname, int def) const {
@@ -234,7 +234,7 @@
   switch (type) {
   case REG_BINARY:
     {
-      TCharArray hex = rdr::HexOutStream::binToHexStr(data.buf, length);
+      TCharArray hex(rdr::HexOutStream::binToHexStr(data.buf, length));
       return hex.takeBuf();
     }
   case REG_SZ:
@@ -272,7 +272,7 @@
 
 bool RegKey::isValue(const TCHAR* valname) const {
   try {
-    TCharArray tmp = getRepresentation(valname);
+    TCharArray tmp(getRepresentation(valname));
     return true;
   } catch(rdr::Exception) {
     return false;
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index 0af5064..f14b49f 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -118,7 +118,7 @@
   // If we successfully start()ed then perform the DisconnectAction
   if (core) {
     CurrentUserToken cut;
-    CharArray action = disconnectAction.getData();
+    CharArray action(disconnectAction.getData());
     if (stricmp(action.buf, "Logoff") == 0) {
       if (!cut.h)
         vlog.info("ignoring DisconnectAction=Logoff - no current user");
diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx
index 2b11a22..a24b651 100644
--- a/win/rfb_win32/Service.cxx
+++ b/win/rfb_win32/Service.cxx
@@ -534,7 +534,7 @@
 		services.openKey(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\RunServices"));
 
     // - Read the command-line from it
-    TCharArray cmdLine = services.getString(name);
+    TCharArray cmdLine(services.getString(name));
 
     // - Start the service
     PROCESS_INFORMATION proc_info;
diff --git a/win/rfb_win32/Win32Util.cxx b/win/rfb_win32/Win32Util.cxx
index 2e17100..5c283df 100644
--- a/win/rfb_win32/Win32Util.cxx
+++ b/win/rfb_win32/Win32Util.cxx
@@ -63,7 +63,7 @@
     langId = langId >> 8;
   }
 
-  TCharArray langIdStr = rdr::HexOutStream::binToHexStr(langIdBuf, sizeof(langId));
+  TCharArray langIdStr(rdr::HexOutStream::binToHexStr(langIdBuf, sizeof(langId)));
   TCharArray infoName(_tcslen(_T("StringFileInfo")) + 4 + _tcslen(name) + _tcslen(langIdStr.buf));
   _stprintf(infoName.buf, _T("\\StringFileInfo\\%s\\%s"), langIdStr.buf, name);
 
diff --git a/win/vncviewer/CConnOptions.cxx b/win/vncviewer/CConnOptions.cxx
index ea0941e..6069e95 100644
--- a/win/vncviewer/CConnOptions.cxx
+++ b/win/vncviewer/CConnOptions.cxx
@@ -324,7 +324,7 @@
                     _T("Storing the password is more convenient but poses a security risk."),
                     MB_YESNO | MB_DEFBUTTON2 | MB_ICONWARNING) == IDYES) {
         ObfuscatedPasswd obfPwd(password);
-        CharArray obfuscatedHex = rdr::HexOutStream::binToHexStr(obfPwd.buf, obfPwd.length);
+        CharArray obfuscatedHex(rdr::HexOutStream::binToHexStr(obfPwd.buf, obfPwd.length));
         fprintf(f, "Password=%s\n", obfuscatedHex.buf);
       }
     }
diff --git a/win/vncviewer/CConnThread.cxx b/win/vncviewer/CConnThread.cxx
index cfd2695..0767ffc 100644
--- a/win/vncviewer/CConnThread.cxx
+++ b/win/vncviewer/CConnThread.cxx
@@ -95,7 +95,7 @@
         try {
           if (isConfig) {
             // A configuration file name was specified - load it
-            CharArray filename = hostOrConfig.takeBuf();
+	    CharArray filename(hostOrConfig.takeBuf());
             options.readFromFile(filename.buf);
           } else {
             // An actual hostname (and possibly port) was specified
diff --git a/win/vncviewer/MRU.h b/win/vncviewer/MRU.h
index ae703b3..fd9bf71 100644
--- a/win/vncviewer/MRU.h
+++ b/win/vncviewer/MRU.h
@@ -48,9 +48,9 @@
           key.getBinary(_T("Order"), (void**)&order.buf, &length);
 
           for (int i=0; i<length; i++) {
-            TCharArray keyname = rdr::HexOutStream::binToHexStr(&order.buf[i], 1);
+	    TCharArray keyname(rdr::HexOutStream::binToHexStr(&order.buf[i], 1));
             try {
-              TCharArray entry = key.getString(keyname.buf);
+              TCharArray entry(key.getString(keyname.buf));
               mru.push_back(strDup(entry.buf));
             } catch (rdr::Exception) {
             }
@@ -79,9 +79,9 @@
           keycode = 0;
           bool found = false;
           for (int i=0; i<orderlen; i++) {
-            TCharArray keyname = rdr::HexOutStream::binToHexStr(&order[i], 1);
+            TCharArray keyname(rdr::HexOutStream::binToHexStr(&order[i], 1));
             try {
-              TCharArray hostname = key.getString(keyname.buf);
+              TCharArray hostname(key.getString(keyname.buf));
               if (stricmp(name, CStr(hostname.buf)) == 0) {
                 keycode = order[i];
                 found = true;
@@ -119,7 +119,7 @@
           order[i] = order[i-1];
         order[0] = keycode;
 
-        TCharArray keyname = rdr::HexOutStream::binToHexStr((char*)&keycode, 1);
+        TCharArray keyname(rdr::HexOutStream::binToHexStr((char*)&keycode, 1));
         key.setString(keyname.buf, TStr(name));
         key.setBinary(_T("Order"), order, orderlen);
       }