Customers




Developers Resources

Blog

05.02.2010 /Wp64 switch and template processing error
While maintaining the analyzer Viva64 (included into PVS-Studio) we often comment upon the switch /Wp64 of Microsoft Visual C++.»

03.02.2010 Parallel notes N1 - OpenMP technology
In the next few posts we will tell you about using multi-core processors in practice.»

29.01.2010 64-bit technologies - one more trend in the modern software
In the blogs and forums, there is much discussion of multi-core processors as an evident step of computer system development.»

Blog RSS

News

2.02.2010 "Lessons of 64-bit C/C++ software development" are now available on our site.»

1.02.2010 PVS-Studio 3.45 New Version Released!»

21.01.2010 PVS-Studio 3.44 New Version Released!»

News RSS

Articles

10.12.2009 PVS-Studio FAQ
This paper contains some questions and answers about PVS-Studio code analyzer by OOO "Program Verification Systems".»

09.12.2009 VivaCore FAQ
This paper contains some questions and answers about VivaCore C/C++ code analysis library by OOO "Program Verification Systems"»

23.11.2009 PVS-Studio: using the function "Mark as False Alarm"
The article describes and demonstrates by an example the use of PVS-Studio 3.40 new function "Mark as False Alarm". »

Articles RSS

Documentation

PVS-Studio Send comments on this topic.
V301. Unexpected function overloading behavior. See NN argument of function 'FOO' in derived class 'DerivedClassName' and base class 'BaseClassName'

The analyzer found a possible error related to the changes in the overriding virtual functions behavior.

The example of the change in the virtual function behavior.

 
class CWinApp {
  ...
  virtual void WinHelp(DWORD_PTR dwData, UINT nCmd);
  ...
};

class CSampleApp : public CWinApp {
  ...
  virtual void WinHelp(DWORD dwData, UINT nCmd);
  ...
};

It is the common example which the developer may face while porting his application to the 64-bit architecture. Let's follow the life-cycle of the developing of some application. Suppose it was being developed for Visual Studio 6.0. at first when the function WinHelp in class CWinApp had the following prototype:

 
virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);

It would be absolutely correct to implement the overlap of the virtual function in class CSampleApp, as it is shown in the example. Then the project was placed into Visual Studio 2005 where the prototype of the function in class CWinApp underwent changes that consist in replacing DWORD type with DWORD_PTR type. On the 32-bit platform this program will continue to work properly for here DWORD and DWORD_PTR types coincide. Troubles will occur while compliling this code for the 64-bit platform. We get two functions with the same names but with different parameters the result of which is that the user's code won't be called.

The analyzer allows to find such errors the correction of which is not difficult. It is enough to change the function prototype in the successor class as follows:

 
class CSampleApp : public CWinApp {
  ...
  virtual void WinHelp(DWORD_PTR dwData, UINT nCmd);
  ...
};

See also:

Limitation