title: Code optimization problem with variable argument list C++
body: <p>I'm using Visual Studio C++ 2010 Express. I made this function with variable argument list:</p>
  
  <pre><code>BOOL Send(SOCKADDR_IN toAddr, LPTSTR command, LPTSTR first, ...) {
   if (g_udpSocket == INVALID_SOCKET || command == NULL)
    return FALSE;
  
   va_list args; 
   va_start(args, command);
   LPTSTR str = va_arg(args, LPTSTR);
   TCHAR szData[DEFAULT_STR_LEN] = {0};
   _tcscpy(szData, command);      
   while (str != NULL) {
    _tcscat(szData, TEXT(" "));
    _tcscat(szData, str);
    str = va_arg(args, LPTSTR);
   }
   va_end(args);
  
   TCHAR szEncrypted[DEFAULT_STR_LEN] = {0};
   DWORD bytesEncrypted = EncryptString((LPBYTE)szData, _tcslen(szData) * sizeof(TCHAR), (LPBYTE)szEncrypted, DEFAULT_STR_LEN * sizeof(TCHAR));
  
   return sendto(g_udpSocket, (char*)szEncrypted, bytesEncrypted, 0, (SOCKADDR*) &amp;toAddr, sizeof(toAddr)) &gt; 0;
  }
  </code></pre>
  
  <p>Example call:</p>
  
  <pre><code>Send(g_listener, CMD_APP, currentAppTitle, NULL);
  </code></pre>
  
  <p>I'm using NULL to indicate that the parameters list ended. Everything runs fine on debug configuration, but when I switch to release the optimizations mess up the variable argument. Any type of optimization doesn't work (/Od, /O1, /O2, ...).</p>
  
  <p>Despite the fact I'm using TCHAR macros, the project is not using UNICODE nor MBCS.</p>
  
  <p>Any ideas how to keep optimizations on (minimize size) and make the variable argument list work?</p>
  
  <p>Thanks,
  Arth</p>