public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
@ 2024-05-08 19:26 ` anlauf at gcc dot gnu.org
2024-05-08 19:29 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-08 19:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
The problem seems to generally occur for class components of derived types.
program p
implicit none
type t
integer :: i = 0
end type t
type any_matrix
class(t), allocatable :: m(:,:)
end type any_matrix
type(any_matrix) :: a, b
allocate(a%m(3,4))
call foo ()
contains
subroutine foo ()
b = a ! Array bound mismatch for dimension 1 of array '<<unknown>>'
(12/3)
!b%m = a%m ! no runtime error with -fcheck=bounds
end subroutine foo
end
This fails as indicated.
Note that 12=3*4 is the total size of the array, and 3 is the size of the
first dimension, which - along with the '<<unknown>>' - points to
gfc_copy_class_to_class:
from_len = gfc_conv_descriptor_size (from_data, 1);
from_len = fold_convert (TREE_TYPE (orig_nelems), from_len);
tmp = fold_build2_loc (input_location, NE_EXPR,
logical_type_node, from_len, orig_nelems);
msg = xasprintf ("Array bound mismatch for dimension %d "
"of array '%s' (%%ld/%%ld)",
1, name);
gfc_trans_runtime_check (true, false, tmp, &body,
&gfc_current_locus, msg,
fold_convert (long_integer_type_node,
orig_nelems),
fold_convert (long_integer_type_node,
from_len));
So we compare dimension 1 and the full size of the rhs?
Shouldn't we compare lhs and rhs shapes?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
2024-05-08 19:26 ` [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components anlauf at gcc dot gnu.org
@ 2024-05-08 19:29 ` anlauf at gcc dot gnu.org
2024-05-13 20:30 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-08 19:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
--- Comment #3 from anlauf at gcc dot gnu.org ---
The code fragment in comment#2 was added in r7-3760-g92c5266bbd5378.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
2024-05-08 19:26 ` [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components anlauf at gcc dot gnu.org
2024-05-08 19:29 ` anlauf at gcc dot gnu.org
@ 2024-05-13 20:30 ` anlauf at gcc dot gnu.org
2024-05-24 19:30 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-13 20:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
Keywords| |wrong-code
--- Comment #4 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2024-May/060512.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2024-05-13 20:30 ` anlauf at gcc dot gnu.org
@ 2024-05-24 19:30 ` cvs-commit at gcc dot gnu.org
2024-05-25 18:50 ` cvs-commit at gcc dot gnu.org
2024-05-25 18:54 ` anlauf at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-24 19:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:93765736815a049e14d985b758a213cfe60c1e1c
commit r15-827-g93765736815a049e14d985b758a213cfe60c1e1c
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon May 13 22:06:33 2024 +0200
Fortran: fix bounds check for assignment, class component [PR86100]
gcc/fortran/ChangeLog:
PR fortran/86100
* trans-array.cc (gfc_conv_ss_startstride): Use abridged_ref_name
to generate a more user-friendly name for bounds-check messages.
* trans-expr.cc (gfc_copy_class_to_class): Fix bounds check for
rank>1 by looping over the dimensions.
gcc/testsuite/ChangeLog:
PR fortran/86100
* gfortran.dg/bounds_check_25.f90: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2024-05-24 19:30 ` cvs-commit at gcc dot gnu.org
@ 2024-05-25 18:50 ` cvs-commit at gcc dot gnu.org
2024-05-25 18:54 ` anlauf at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-25 18:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:b0b21d5bdfbc7d417b70010a11354b44968bb184
commit r14-10244-gb0b21d5bdfbc7d417b70010a11354b44968bb184
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon May 13 22:06:33 2024 +0200
Fortran: fix bounds check for assignment, class component [PR86100]
gcc/fortran/ChangeLog:
PR fortran/86100
* trans-array.cc (gfc_conv_ss_startstride): Use abridged_ref_name
to generate a more user-friendly name for bounds-check messages.
* trans-expr.cc (gfc_copy_class_to_class): Fix bounds check for
rank>1 by looping over the dimensions.
gcc/testsuite/ChangeLog:
PR fortran/86100
* gfortran.dg/bounds_check_25.f90: New test.
(cherry picked from commit 93765736815a049e14d985b758a213cfe60c1e1c)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2024-05-25 18:50 ` cvs-commit at gcc dot gnu.org
@ 2024-05-25 18:54 ` anlauf at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-25 18:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |14.2
Status|NEW |RESOLVED
--- Comment #7 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-15, and backported to 14-branch. Closing.
Thanks for the report, and sorry that it took so long to fix.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-25 18:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/>
2024-05-08 19:26 ` [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components anlauf at gcc dot gnu.org
2024-05-08 19:29 ` anlauf at gcc dot gnu.org
2024-05-13 20:30 ` anlauf at gcc dot gnu.org
2024-05-24 19:30 ` cvs-commit at gcc dot gnu.org
2024-05-25 18:50 ` cvs-commit at gcc dot gnu.org
2024-05-25 18:54 ` anlauf 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).