Microsoft KB Archive/240626

= BUG: Extra lines are generated in assembly code when you Use #line directive in Visual C++ =

Article ID: 240626

Article Last Modified on 6/1/2005

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q240626



SYMPTOMS
While using #line digit-sequence "filename" with Visual C++ 6.0, extra lines may be generated in assembly code. Hence, you may need to press F10 multiple times while debugging to go to the next executable line.



CAUSE
Extra lines are generated for the #line directive.



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



Steps to reproduce the behavior
Compile Main.cpp: /*******************************************  Main.cpp file Uses #line directives. ******************************************/

void main { int xx = 1;
 * 1) include 
 * 2) line 1 "thetestfile"
 * 1) line 1 "thetestfile"
 * 1) line 1 "thetestfile"

if (xx == 1) { printf("hello1\n"); ++xx; }
 * 1) line 1 "thetestfile"
 * 1) line 1 "thetestfile"
 * 1) line 1 "thetestfile"
 * 1) line 1 "thetestfile"
 * 1) line 1 "thetestfile"

if (xx == 2) { int r = 0; printf("hello2\n"); }
 * 1) line 2 "thetestfile"
 * 1) line 2 "thetestfile"
 * 1) line 2 "thetestfile"
 * 1) line 2 "thetestfile"

if (xx == 2) { int r = 0; printf("hello3\n"); }
 * 1) line 3 "thetestfile"
 * 1) line 3 "thetestfile"
 * 1) line 3 "thetestfile"
 * 1) line 3 "thetestfile"
 * 1) line 3 "thetestfile"

} Create a text file named thetestfile, and add the following lines to the file: line 1 : Write hello1 on console line 2 : Write hello2 on console line 3 : Write hello3 on console The following is the generated assembly code: 1:   line 1 : Write hello1 on console 00401010  push        ebp 00401011  mov         ebp,esp 00401013  sub         esp,4Ch 00401016  push        ebx 00401017  push        esi 00401018  push        edi 00401019  lea         edi,[ebp-4Ch] 0040101C  mov         ecx,13h 00401021  mov         eax,0CCCCCCCCh 00401026  rep stos    dword ptr [edi] 00401028  mov         dword ptr [ebp-4],1 0040102F  cmp         dword ptr [ebp-4],1 00401033  jne         main+3Bh (0040104b) 00401035  push        offset string "hello1\n" (00420034) 0040103A  call        printf (004010b0) 0040103F  add         esp,4 00401042  mov         eax,dword ptr [ebp-4] 00401045  add         eax,1 00401048  mov         dword ptr [ebp-4],eax 3:   line 3 : Write hello3 on console 0040104B  cmp         dword ptr [ebp-4],2 0040104F  jne         main+55h (00401065) 2:   line 2 : Write hello2 on console 00401051  mov         dword ptr [r],0 2:   line 2 : Write hello2 on console 00401058  push        offset string "hello2\n" (00420028) 0040105D  call        printf (004010b0) 00401062  add         esp,4 3:   line 3 : Write hello3 on console 00401065  cmp         dword ptr [ebp-4],2 00401069  jne         main+6Fh (0040107f) 3:   line 3 : Write hello3 on console 0040106B  mov         dword ptr [r],0 3:   line 3 : Write hello3 on console 00401072  push        offset string "hello3\n" (0042001c) 00401077  call        printf (004010b0) 0040107C  add         esp,4 4: 0040107F  pop         edi 00401080  pop         esi 00401081  pop         ebx 00401082  add         esp,4Ch 00401085  cmp         ebp,esp 00401087  call        __chkesp (00401130) 0040108C  mov         esp,ebp 0040108E  pop         ebp 0040108F  ret Extra lines are generated for line 2 and line 3 directives. As a result, you need to press F10 multiple times for line 2 and line 3 while debugging.

Additional query words: #line directive extra line F10

Keywords: kbbug kbdebug kbcodegen kbcompiler KB240626

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.