Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28655 Discussions

breakpoint in "if()then.." breaks when it shouldn't

Ralf
Beginner
279 Views
Hi all,
sorry for the rather vague question but I could not reproduce my problem in a small code example (which worked perfectly ok), but maybe some of you encountered something similar and can provide an answer nonetheless.
In my code I have something similar to:
------
logical :: valid
call foo( valid )
if (valid ) then
! <- *always* breaks here, independent of 'valid'
endif
------
A breakpoint set inside the if-statement always breaks, independent of the value of 'valid'
('valid' is set in host-associated routine 'foo')
Any guesses why?
Cheers
-Ralf
p.s.Fortran Composer XE 2011, Win7 (same behaviour on win32 & x64).
0 Kudos
4 Replies
Anonymous66
Valued Contributor I
279 Views

Hello Ralf,

If you can't reproduce it in a small example program, could you attach your original program?

0 Kudos
jimdempseyatthecove
Honored Contributor III
279 Views
Ralf,

This may depend on the optimizations. The newer generation processors have a conditional move instruction. This instruction is used to avoid branches. If your code is something like

if(valid) then
a = b
endif

The code generated (pseudo code) would look like

move tempReg, b ! dest, src
test valid
conditional move on true a, tempReg

There is no branches in the above code.

When there are no branches then there is no way to conditionally break (since you cannot break in the middle of an instruction).

You can look at the dissassembly code to confirm if this is the case.

As a work around you can do something like

if(valid) then
if(expression) write(*,*) "expression known to be false"
a = b
endif

Where the expression cannot be predetermined by the compiler as to always being true or false.
The above will generate a branch which then will isolate the breakpoint to the (true) path.

Jim Dempsey
0 Kudos
Ralf
Beginner
279 Views

Hello Ralf,

If you can't reproduce it in a small example program, could you attach your original program?

Thank you Annalee but I'd rather not - it is just an annoyance I can work around it.

Cheers

-Ralf

0 Kudos
Ralf
Beginner
279 Views
Ralf,

This may depend on the optimizations. The newer generation processors have a conditional move instruction. This instruction is used to avoid branches. If your code is something like

[snip]

There is no branches in the above code.

When there are no branches then there is no way to conditionally break (since you cannot break in the middle of an instruction).

You can look at the dissassembly code to confirm if this is the case.

As a work around you can do something like

if(valid) then
if(expression) write(*,*) "expression known to be false"
a = b
endif

Where the expression cannot be predetermined by the compiler as to always being true or false.
The above will generate a branch which then will isolate the breakpoint to the (true) path.

Jim Dempsey

Thanks Jim,
I'll try your workaround.
Cheers
-Ralf
0 Kudos
Reply