public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/65677] New: Incomplete assignment on deferred-length character variable
@ 2015-04-06 14:59 jwmwalrus at gmail dot com
2015-04-15 9:28 ` [Bug fortran/65677] " dominiq at lps dot ens.fr
0 siblings, 1 reply; 2+ messages in thread
From: jwmwalrus at gmail dot com @ 2015-04-06 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65677
Bug ID: 65677
Summary: Incomplete assignment on deferred-length character
variable
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jwmwalrus at gmail dot com
The code below fails to produce the expected results.
module mod1
implicit none
contains
subroutine getKeyword(string, keyword, rest)
character(:), allocatable, intent(IN) :: string
character(:), allocatable, intent(OUT) :: keyword, rest
integer :: idx
character(:), allocatable :: text
keyword = ''
rest = ''
text = string
text = ADJUSTL(text(2:)) !***
idx = INDEX(text, ' ')
if (idx == 0) then
keyword = TRIM(text)
else
keyword = text(:idx-1)
rest = TRIM(ADJUSTL(text(idx+1:)))
endif
end subroutine
end module mod1
use mod1
implicit none
character(:), allocatable :: line, keyword, rest
line = '@HERE IT IS'
call getKeyword(line, keyword, rest)
print *, 'line: ', line
print *, 'keyword: ', keyword
print *, 'rest: ', rest
end
It seems that whenever a deferred-length character variable that's being
assigned something is also a substring in the right-hand side expression,
assignment is wrong/incomplete. The offending line is marked with "!***" in the
code. This is the output I get:
~$ ll `which gfortran-5.0`
lrwxrwxrwx 1 root staff 35 Feb 26 11:01 /usr/local/bin/gfortran-5.0 ->
../../lib/gcc-snapshot/bin/gfortran*
~$ gfortran-5.0 test_deferred.f90
~$ ./a.out
line: @HERE IT IS
keyword: HERE
rest: IT I
So far I've noticed the error occurs only when the substring does not coincide
with the beginning of the string. I get the same error with gfortran 4.9.
The system and compiler information is:
$ lsb_release -rd && gfortran-5.0 -v
Description: Debian GNU/Linux 8.0 (jessie)
Release: 8.0
Using built-in specs.
COLLECT_GCC=gfortran-5.0
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20150404-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id
--disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=c++98
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-snap-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-snap-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-snap-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--disable-werror --enable-checking=yes --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.0.0 20150404 (experimental) [trunk revision 221867] (Debian
20150404-1)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/65677] Incomplete assignment on deferred-length character variable
2015-04-06 14:59 [Bug fortran/65677] New: Incomplete assignment on deferred-length character variable jwmwalrus at gmail dot com
@ 2015-04-15 9:28 ` dominiq at lps dot ens.fr
0 siblings, 0 replies; 2+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-15 9:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65677
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-04-15
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from 4.6 up to trunk (6.0). With 4.6 and 4.7 the output is
line: @HERE IT IS
keyword:
rest:
If I replace the line
text = ADJUSTL(text(2:)) !***
with
text = text(2:) !***
I get the expected behavior.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-15 9:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 14:59 [Bug fortran/65677] New: Incomplete assignment on deferred-length character variable jwmwalrus at gmail dot com
2015-04-15 9:28 ` [Bug fortran/65677] " dominiq at lps dot ens.fr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).