BUG: Expansion of the __LINE__ macro is incorrect when you use Debug Information for Edit and Continue (/ZI) in Visual C++ (199057)



The information in this article applies to:

  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

This article was previously published under Q199057

SYMPTOMS

The results of the __LINE__ macro are incorrect when you use Debug Information for Edit and Continue (/ZI). The problem may manifest itself as compiler, linker, or run-time errors.

WORKAROUND

To work around this problem, use the Program Database option (/Zi) instead of Edit and Continue (/ZI).

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

The following sample code demonstrates the problem.
   // TEST.CPP - Compile with /GX and /Zi or /ZI.
   #include <iostream>
   using namespace std;

   #define CONCAT(s1,s2) #s1 ## #s2
   #define MSG(n) cout << CONCAT(Message at line\x20,n) << endl;

   int main()
   {
   MSG(__LINE__);
   return 0;
   }
				
When compiled with the /Zi option, output is correct:

Message at line 12

When compiled with the /ZI option, output is incorrect:

Message at line (__LINE__Var+1)


Modification Type:MinorLast Reviewed:1/11/2006
Keywords:kbhowto kbBug kbCompiler kbpending KB199057 kbAudDeveloper