- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was writing a procedure to reverse characters on a string and found some bugs and even Internal Compiler Errors.
Consider this case:
program reverse implicit none character(20), parameter :: input = 'Forward' integer i character(len(input)), parameter :: output = & transfer([(input(i:i),i=len_trim(input),1,-1)],trim(input)) print *, input, '#', len(input) print *, output, '#', len(output) end program reverse
My expected output was:
Forward # 20 drawroF # 20
But I got this:
Forward # 20 drawroF# 7
I am getting a len=7 character parameter despite of declaring it as len=20. The trimmed length overwrites the declared length for some reason.
Then, I tried changing the code to remove all trimming, like this:
program reverse implicit none character(20), parameter :: input = 'Forward' integer i character(len(input)), parameter :: output = & transfer([(input(i:i),i=len(input),1,-1)],input) print *, input, '#', len(input) print *, output, '#', len(output) end program reverse
But this produces an "internal error" on the line of the character declaration. Changing this line again to:
character(len(input)), parameter :: output = & transfer([character::(input(i:i),i=len(input),1,-1)],input)
Now produces a "catastrophic error: **Internal compiler error: segmentation violation signal raised**".
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Additional info: I do get the desired output if I remove the `parameter` specifier from it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting code. Your first variant also introduces an ICE with the PGI compiler, nagfor and gfortran show the length as 20, but gfortran removes all blanks and prints only 7 characters, while nagfor prints 20 characters. Intel - as you noted - shows the length as 7 and prints only 7. An ICE (Internal Compiler Error) is always an error of the compiler, so please report this to Intel Online Support Center.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can see the first error with a number of versions of IFort - Windows. Even Compaq Visual Fortran 6.6C has this error.
With Intel Fortran 14.0.6 (Windows), the second and third versions of the test program get compiled with no errors and the output is correct.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page