We have already written about the causes of the warning "Some diagnostic messages may contain incorrect line number for file ...". Let me remind you that multi-line #define directives are processed incorrectly due to the preprocessor error in Visual C++ 2005 (without SP1). This leads to the PVS-Studio positioning error. If you get this warning I recommend that you read this note to understand the reason for that and how to deal with it.
Unfortunately, there is one more case when the warning "Some diagnostic messages may contain incorrect line number for file ..." is generated and a fault in positioning diagnostic warnings occurs. We speak about multi-line #pragma directives of a special kind. Here is an example of correct code:
#pragma warning(push)
void test()
{
int a = 0;
size_t b = a; // PVS-Studio informs about the error here
}
But if you write #pragma directive in two lines PVS-Studio analyzer informs about the error in the wrong place (one-line fault):
#pragma \
warning(push)
void test()
{
int a = 0; // PVS-Studio informs about the error here,
size_t b = a; // but actually it is here.
}
Although in another case with a multi-line #pragma directive there is no error:
#pragma warning \
(push)
void test()
{
int a = 0;
size_t b = a; // PVS-Studio informs about the error in this line
}
Like in the previous note about the warning "Some diagnostic messages may contain incorrect line number for file ...", this error is related to using the Visual C++ preprocessor.
However, this error is not fixed by installing Service Pack 1 on Visual Studio 2005 or moving to Visual Studio 2008. The only recommendation is to either refuse to use multi-line #pragma directives or still use them but in the way they are correctly processed.