Article ID: 199057 - Last Review: January 11, 2006 - Revision: 4.1

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

This article was previously published under Q199057
Expand all | Collapse all

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)

APPLIES TO
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
Keywords: 
kbhowto kbbug kbpending kbcompiler KB199057
 

Article Translations

 

Related Support Centers