NO

Author Topic: Crash .exe compiled with Pelles C 64 on Vista x64  (Read 3412 times)

Offline Robert

  • Member
  • *
  • Posts: 247
Crash .exe compiled with Pelles C 64 on Vista x64
« on: January 22, 2009, 11:27:32 AM »
In the following program, this line

   _tprintf(_T("'%s'\n"), _tcsrev(str));

crashes the .exe compiled with Pelles C 64 on Vista x64.

Compiler command line is

pocc -W1 -Go -Gr -Ze -Zx -Tamd64-coff gentext.c

and the command line for the linker is

polink -release -machine:x64 -subsystem:console -OUT:gentext.exe gentext.obj

Robert Wishlaw

Code: [Select]

// gentext.c
// use of generic-text mappings defined in tchar.h

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <direct.h>
#include <errno.h>
#include <tchar.h>

int __cdecl _tmain(int argc, _TCHAR **argv, _TCHAR **envp)
{
   _TCHAR buff[260];
   _TCHAR *str = _T("Astring");
   char *amsg = "Reversed";
   wchar_t *wmsg = L"Is";

#ifdef _UNICODE
   printf("Unicode version\n");
#else /* _UNICODE */
#ifdef _MBCS
   printf("MBCS version\n");
#else
   printf("SBCS version\n");
#endif
#endif /* _UNICODE */

   if (_tgetcwd(buff, 260) == NULL)
       printf("Can't Get Current Directory - errno=%d\n", errno);
   else
       _tprintf(_T("Current Directory is '%s'\n"), buff);
   _tprintf(_T("'%s' %hs %ls:\n"), str, amsg, wmsg);
   _tprintf(_T("'%s'\n"), _tcsrev(str));
   return 0;
}


JohnF

  • Guest
Re: Crash .exe compiled with Pelles C 64 on Vista x64
« Reply #1 on: January 22, 2009, 12:21:08 PM »
Try

   _TCHAR str[] = _T("Astring");

You are over-writing read only memory otherwise.

John

Offline Robert

  • Member
  • *
  • Posts: 247
Re: Crash .exe compiled with Pelles C 64 on Vista x64
« Reply #2 on: January 22, 2009, 09:58:46 PM »
Thank you John, that solved the problem and the crash no longer occurs.

Robert Wishlaw