To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
USD
EUR
RUB
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
Strange errors occurring when compiling…

Strange errors occurring when compiling the 64-bit version of an application, error C2664

Apr 05 2013
Author:

Sometimes you may see questions about strange errors generated by the compiler when building 64-bit code.

A question may look in the following way:

//Class definition
class Type1 {...};
class Type2 {...};
class A
{
  public:
  ...
  void Func1(Type1* t1.....);
  void Func1(Type2& t2.....);
  ...
};
//Using Func1 function
A obj;
Type2 t2;
...
obj.Func1(t2,...);
...

This code successfully compiles in the 32-bit mode but the compiler generates the error C2664 (Type2 cannot be cast to Type1*) when trying to build the 64-bit version. Although the function taking Type2& as the argument is defined, the compiler, due to some reason, tries to use the function taking Type1* as the argument. What is the matter?

Most likely, the problem is in the other parameters which were replaced by dots in the example. Here is one more example of the code:

class Type1 {};
class Type2 {};
class A
{
public:
void Func1(Type1* t1, unsigned &);
void Func1(Type2& t2, size_t &);
};
void use() {
  A obj;
  Type2 t2;
  unsigned u;
  obj.Func1(t2, u);
}

It successfully compiles in the 32-bit mode. But in the 64-bit mode the both functions fail to work. The compiler considers the first function a better candidate because its second parameter meets the condition. Yet it announces that the first argument does not suit: error C2664: 'void A::Func1(Type1 *,unsigned int &)' : cannot convert parameter 1 from 'Type2' to 'Type1 *'. The solution is to carefully study the other arguments and modify the code as needed.

Comments (0)

Next comments
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept