Win32 to X64 porting issue.

prxy 61 Reputation points
2020-12-14T13:16:37.43+00:00

Hi,

I'm trying to port x86 project to x64. Debug build is successful, but when I'm trying to build in release mode. I'm getting below error.

Creating library {path\to\output\dir}\projectname.lib and object
{path\to\output\dir}\projectname.exp

1>Generating code
error C4789: buffer 'objTmpToken' of size 352 bytes will be overrun; 524 bytes will be written starting at offset 16
1>LINK : fatal error LNK1257: code generation failed
1>Done building project "{ProjectName}.vcxproj" -- FAILED.

When I disable Whole program optimization, release build gets successful. But I don't want to disable it to be consistent with x86.

Any help would be appreciated ?

Thanks,

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,664 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,538 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Gary Nebbett 5,721 Reputation points
    2020-12-14T14:54:41.167+00:00

    Hello @prxy ,

    You probably have a bug in your code. If you look at the documentation for C4789, you will see that it typically occurs in conjunction with use of the intrinsic versions of these functions: strcpy, memset, memcpy, wmemcpy. When compiling with optimization enabled (release mode), intrinsics are used to implement these functions; when compiling in debug mode, library calls are used. Since the compiler is responsible for generating the intrinsic statements, it is better able to detect overflow problems.

    Gary

    0 comments No comments