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

Article translations Article translations
Article ID: 199057 - View products that this article applies to.
This article was previously published under Q199057
This article has been archived. It is offered "as is" and will no longer be updated.
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)

Properties

Article ID: 199057 - Last Review: February 23, 2014 - Revision: 4.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: 
kbnosurvey kbarchive kbhowto kbbug kbpending kbcompiler KB199057

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com