Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29298 Discussions

VS IDE debugger reports null strings as blank strings.

scitec
Beginner
477 Views

Hello,

I have run into what seems to be an anomaly in the way that the Visual Studio debugger reports the values of strings that contain nulls. They appear in the debugger as strings of blanks. The following test program runs as expected, but if you set breakpoints and enquire about the value of the string, the final case does not yield the report I would have expected.

Perhaps someone will point out that my debug settings are incorrect and guide me to a solution, or perhaps it will just save someone else the confusion it caused me. (I was confused because, althoughmy code handled blank strings correctly, it didn't handle what "looked like" a blank string correctly.)

program Test_Len_Trim

implicit none

Integer intLength
Character*8 strTest

strTest = ' a b ' ! Appears in debugger as ' a b '.
intLength = Len_Trim(strTest)
Write(6,*) Len(strTest), intLength

strTest = '' ! Appears in debugger as ' ',
intLength = Len_Trim(strTest) ! as expected.
Write(6,*) Len(strTest), intLength

strTest = Repeat(Char(11),16) ! Appears in debugger as ' ',
intLength = Len_Trim(strTest) ! as seems reasonable.
Write(6,*) Len(strTest), intLength

strTest = Repeat(Char(0),16) ! Appears in debugger as ' ',
intLength = Len_Trim(strTest) ! not as expected.
Write(6,*) Len(strTest), intLength

Pause

end program Test_Len_Tri m

Cheers,

Randy

0 Kudos
2 Replies
scitec
Beginner
477 Views

Clarification:

In the third case, the debugger shows a string of Char(11) characters as a series of square boxes, as seems customary for control characters. (It seems that the web site doesn't like to show these characters, so the comment in my copy and paste doesn't reflect the comment that is actually in the code.

Cheers,
Randy

0 Kudos
Steven_L_Intel1
Employee
477 Views

Yeah, the debugger thinks of strings as C strings and stops at a NUL. I'm not sure if this is something we can change. You can examine the variable in the Memory window and see all the bytes.

0 Kudos
Reply