public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/108680] New: Wrong DTIO arguments with -fdefault-integer-8
@ 2023-02-05 19:56 albandil at atlas dot cz
2023-02-06 16:40 ` [Bug fortran/108680] " kargl at gcc dot gnu.org
2024-03-06 3:17 ` jvdelisle at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: albandil at atlas dot cz @ 2023-02-05 19:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108680
Bug ID: 108680
Summary: Wrong DTIO arguments with -fdefault-integer-8
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: albandil at atlas dot cz
Target Milestone: ---
Wrong DTIO arguments with -fdefault-integer-8
It seems that gfortran miscompiles the following simple program when
`-fdefault-integer-8` compiler option is used:
module types
type dtype
contains
procedure :: write_formatted
generic, public :: write(formatted) => write_formatted
end type
contains
subroutine write_formatted (this, unit, iotype, v_list, iostat, iomsg)
class(dtype), intent(in) :: this
integer, intent(in) :: unit, v_list(:)
character(*), intent(in) :: iotype
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
iostat = 0
print *, 'v_list', v_list
end subroutine write_formatted
end module types
program p
use types, only: dtype
type(dtype) :: data
integer :: u
open (file = 'output.txt', newunit = u, form = 'formatted')
write (u, '(dt(1,2,3))') data
close (u)
end program p
The derived type `dtype` should be given integers 1,2,3 in the v_list parameter
of the `write(formatted)` subroutine, which only echoes them out for feedback.
This works with Intel compilers regardless of the default integer type.
However, the output is wrong if I combine gfortran `-fdefault-integer-8`. The
behaviour is the same with the current git version as well as with GCC release
11.3, so the problem has been around for some time.
$ /opt/gcc-git/bin/gfortran --version | head -n 1
GNU Fortran (GCC) 13.0.1 20230205 (experimental)
$ /opt/gcc-git/bin/gfortran main.f90
$ ./a.out
v_list 1 2 3
$ /opt/gcc-git/bin/gfortran -fdefault-integer-8 main.f90
$ ./a.out
v_list 8589934593 3 0
$ gfortran-11 --version | head -n 1
GNU Fortran (SUSE Linux) 11.3.1 20221024 [revision
bd0c76a2329e7fe6d6612c2259647bbb67f5866a]
$ gfortran-11 -fdefault-integer-8 main.f90
$ ./a.out
v_list 8589934593 3 0
$ ifx --version | head -n 1
ifx (IFORT) 2023.0.0 20221201
$ ifx -i8 main.f90
$ ./a.out
v_list 1 2 3
$ ifort --version | head -n 1
ifort (IFORT) 2021.8.0 20221119
$ ifort -i8 main.f90
$ ./a.out
v_list 1 2 3
It looks as if the subroutine was actually getting pointers to 4-byte integers
regardless of the switch, because the large value pritned first is actually
composition of the missing 2 and 1:
8589934593 ~ 00000000000000000000000000000010
00000000000000000000000000000001
~ 2 1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/108680] Wrong DTIO arguments with -fdefault-integer-8
2023-02-05 19:56 [Bug fortran/108680] New: Wrong DTIO arguments with -fdefault-integer-8 albandil at atlas dot cz
@ 2023-02-06 16:40 ` kargl at gcc dot gnu.org
2024-03-06 3:17 ` jvdelisle at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-02-06 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108680
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
I submitted a patch years ago to remove the -fdefault*
options, because these options have all sorts of problem.
The only compelling reason for these options is to allow
a user to compile code **while porting from INTEGER(4)
to INTEGER(8)**. That patch was rejected.
-fdefault-integer-8 simply will not work with DTIO as
it seems that there is no runtime library support.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/108680] Wrong DTIO arguments with -fdefault-integer-8
2023-02-05 19:56 [Bug fortran/108680] New: Wrong DTIO arguments with -fdefault-integer-8 albandil at atlas dot cz
2023-02-06 16:40 ` [Bug fortran/108680] " kargl at gcc dot gnu.org
@ 2024-03-06 3:17 ` jvdelisle at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-03-06 3:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108680
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-03-06
Assignee|unassigned at gcc dot gnu.org |jvdelisle at gcc dot gnu.org
Ever confirmed|0 |1
CC| |jvdelisle at gcc dot gnu.org
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Taking a quick look at this one. Yes it handles -fdefault-integer-8
incorrectly. I agree with Steve in that this is not a Standard Fortran feature.
The right way to allow changing kinds is to use a parameter defined with for
example select_integer_kind in a module or something and have that parameter
used everywhere. Obviously not conveniant.
Regardless even if one declares integer 8 everywhere, the vlist is screwed up.
Adding to my list.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-06 3:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-05 19:56 [Bug fortran/108680] New: Wrong DTIO arguments with -fdefault-integer-8 albandil at atlas dot cz
2023-02-06 16:40 ` [Bug fortran/108680] " kargl at gcc dot gnu.org
2024-03-06 3:17 ` jvdelisle at gcc dot gnu.org
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).