- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've come across something a little bit strange when debugging code that contains parameters.
Here's the test code:
subroutine tnmenu (ipltflg,iwin,angl_in)
real HALF2
parameter (HALF2 = 0.5)
c HALF2 = 0.5
if (irot .lt. 1) then
cenx = cenx + HALF2
ceny = ceny + HALF2
end if
return
end
Here's the assembly when NOT using a parameter:
if (irot .lt. 1) then
00412AE3 mov eax,dword ptr [IROT]
00412AE6 test eax,eax
00412AE8 jg TNMENU+2Ch (412B00h)
cenx = cenx + HALF2
00412AEA fld dword ptr [CENX]
00412AED fld dword ptr [HALF2]
00412AF0 faddp st(1),st
00412AF2 fstp dword ptr [CENX]
ceny = ceny + HALF2
00412AF5 fld dword ptr [CENY]
00412AF8 fld dword ptr [HALF2]
00412AFB faddp st(1),st
00412AFD fstp dword ptr [CENY]
end if
It works properly. But, when I use the PARAMETER statement, here's what I get:
if (irot .lt. 1) then
00412ADA mov eax,dword ptr [IROT]
00412ADD test eax,eax
00412ADF jg TNMENU+29h (412AFDh)
cenx = cenx + HALF2
00412AE1 fld dword ptr [CENX]
ceny = ceny + HALF2
00412AE4 fld dword ptr [TNMENU$BLK_debug_param_const-4 (42D000h)]
cenx = cenx + HALF2
00412AEA faddp st(1),st
00412AEC fstp dword ptr [CENX]
ceny = ceny + HALF2
00412AEF fld dword ptr [CENY]
00412AF2 fld dword ptr [TNMENU$BLK_debug_param_const-4 (42D000h)]
00412AF8 faddp st(1),st
00412AFA fstp dword ptr [CENY]
end if
When I step through the program in Visual Studio 2003 it runs through the statements twice (although it only executes them once).
I used the following compile options:
ifort /debug-parameters out:tnmenu.obj /Zi /Od /iface:cvf /traceback /check:bounds /libs:dll /threads /c tnmenu.for
Version: W_FC_C_9.0.025
I tried other options as well but nothing seemed to correct the problem.
Ideas?
Ian
Here's the test code:
subroutine tnmenu (ipltflg,iwin,angl_in)
real HALF2
parameter (HALF2 = 0.5)
c HALF2 = 0.5
if (irot .lt. 1) then
cenx = cenx + HALF2
ceny = ceny + HALF2
end if
return
end
Here's the assembly when NOT using a parameter:
if (irot .lt. 1) then
00412AE3 mov eax,dword ptr [IROT]
00412AE6 test eax,eax
00412AE8 jg TNMENU+2Ch (412B00h)
cenx = cenx + HALF2
00412AEA fld dword ptr [CENX]
00412AED fld dword ptr [HALF2]
00412AF0 faddp st(1),st
00412AF2 fstp dword ptr [CENX]
ceny = ceny + HALF2
00412AF5 fld dword ptr [CENY]
00412AF8 fld dword ptr [HALF2]
00412AFB faddp st(1),st
00412AFD fstp dword ptr [CENY]
end if
It works properly. But, when I use the PARAMETER statement, here's what I get:
if (irot .lt. 1) then
00412ADA mov eax,dword ptr [IROT]
00412ADD test eax,eax
00412ADF jg TNMENU+29h (412AFDh)
cenx = cenx + HALF2
00412AE1 fld dword ptr [CENX]
ceny = ceny + HALF2
00412AE4 fld dword ptr [TNMENU$BLK_debug_param_const-4 (42D000h)]
cenx = cenx + HALF2
00412AEA faddp st(1),st
00412AEC fstp dword ptr [CENX]
ceny = ceny + HALF2
00412AEF fld dword ptr [CENY]
00412AF2 fld dword ptr [TNMENU$BLK_debug_param_const-4 (42D000h)]
00412AF8 faddp st(1),st
00412AFA fstp dword ptr [CENY]
end if
When I step through the program in Visual Studio 2003 it runs through the statements twice (although it only executes them once).
I used the following compile options:
ifort /debug-parameters out:tnmenu.obj /Zi /Od /iface:cvf /traceback /check:bounds /libs:dll /threads /c tnmenu.for
Version: W_FC_C_9.0.025
I tried other options as well but nothing seemed to correct the problem.
Ideas?
Ian
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're getting some optimization with "constant folding" when using PARAMETERs, and this can allow some instructions to move around. The apparent repeat is an artifact of the way the debug line numbers are associated with instructions. There are many other places you can see what looks like jumping around when the compiler has reordered the instructions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a way that I can disable this optimization? I thought that in debug all optimizations were off. This is a simple scenario that I set up to demonstrate this issue, but in my application I get line jumping throughout the program which can make it tedious to debug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not that I know of - sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would it be possible to submit this as a bug?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can certainly submit a complaint about it. I'm unsure it qualifies as a bug, but the complaint will be passed on to development and perhaps there's something that can be done about it.
I will say, though, from past experience on a different compiler, that this is a hard problem to solve when the debug language is relatively simplistic about how source line correlation is done.
I will say, though, from past experience on a different compiler, that this is a hard problem to solve when the debug language is relatively simplistic about how source line correlation is done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If something could be done that would be great. Perhaps it would be easier to just have an option to disable that optimization. In any case, what's the process for submitting that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Specify "Feature Request" in Intel Premier Support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect. Thank you for all of your help.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page