Silverfrost Forums

Welcome to our forums

Character string is lost

11 Nov 2024 7:49 #31678

I have what seems to be an impossible-to-report problem with a character string getting lost in the 64-bit version! The core of the problem looks something like the following:

Use m, Only: c2 ! c2 is a character string
Character(Len=16) :: c1
Write ( Unit=c1, Fmt='(A)' ) c2
c1 = c1 ! bug is avoided with this line, as long as this comment is deleted!
Print * c1

I recognise that the above is incomplete code, so it cannot be tested. But I don't know where to begin to start to create an example to illustrate this because the bug does not occur when (a) compiling in 32-bit, (b) adding useless lines like line 4. Even more perplexing, the problem reappears when adding a comment to line 4, and it can also be made to disappear if I delete code that is never even called. The full code is about 160,000 lines. I am happy to try to forward that to Paul if diagnosing this problem does not look like a massive task.

12 Nov 2024 7:47 #31680

Simon

I have not seen UNIT=<character variable> before. Is that legal? It is not faulted by FTN95 but perhaps it should be.

13 Nov 2024 8:10 #31695

Hi Paul, I've been using Unit=character for years, actually probably decades. Actually, in this case, I don't think it is integral to the problem I am experiencing since I have other examples that do not use this construct anyway. But, yes, it is probably worth checking how FTN95 handles it. I am uncertain of what the Fortran standard is, but my understanding is that Unit becomes a negative number when it is using an internal file. But it may well be illegal to attempt to pass the character explicitly as the Unit number. If anybody knows I would be happy to hear. Simon

14 Nov 2024 7:41 #31697

Simon

Ah yes. I did not recognise it as an internal write statement.

Have you looked at the point of failure using the debugger? Have you tried omitting the ONLY in the USE statement?

16 Nov 2024 12:24 #31706

Hi Paul, Unfortunately, if I try to compile using /DEBUG /CHECK, I get the following error somewhere else in the program:

AMD backend failure:Failed to do register-memory emit for MOV_Q at ...

in each case at a Subroutine declaration. Plus I get some Internal compiler errors, again at some Subroutine declarations. None of these problems occur when compiling without those options, nor do they occur when compiling in 32-bit, with or without.

16 Nov 2024 7:58 #31707

Simon

  1. Please send a simple program that illustrates the /64 /CHECK failure. This is probably something that we need to fix.

  2. Try using /DEBUG on its own. That might help you to work out what is going wrong.

16 Nov 2024 4:32 #31709

Hi Paul, I will try to send a simple program, but I estimate it will take more than a full day's work, so I can't promise to do it soon. If I remove /CHECK, then I no longer et compilation errors. and some of the runtime errors go away. When I get some free time, I will try to isolate all these issues ...

19 Nov 2024 3:26 #31714

Here are portions of F2008 that pertain:

F2008: 9.6.2R913: io-control-spec is UNIT = io-unit OR ... 9.5.1: R901: io-unit is file-unit-number OR * OR internal-file-variable

Here is the source of a modified version of the test program that runs correctly with the 9.05 version of FTN95

module m
character(12) :: c2 = 'String c2xyz'
end module

program buggy
Use m, Only: c2 ! c2 is a character string
Character(Len=16) :: c1
Write ( Unit=c1, Fmt='(A)' ) c2
Print *, c1 
end program
19 Nov 2024 4:37 #31718

Thanks for the confirmation. It appears that my partial code was legal, so I'll have to try and find a way to isolate the problem.

Please login to reply.