public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR
@ 2024-02-10 17:31 dcb314 at hotmail dot com
2024-02-10 17:55 ` [Bug fortran/113866] " kargl at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dcb314 at hotmail dot com @ 2024-02-10 17:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
Bug ID: 113866
Summary: ice in generic_simplify_COND_EXPR
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
Created attachment 57380
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57380&action=edit
F90 source code
For this F90 source code file:
./Lower/HLFIR/bindc-assumed-length.f90
from the flang testsuite at
https://github.com/llvm/llvm-project/tree/main/flang/test
when compiled by recent gfortran, does this:
est $ ~/gcc/results.20240210.asan.ubsan/bin/gfortran -c -w
./Lower/HLFIR/bindc-assumed-length.f90
./Lower/HLFIR/bindc-assumed-length.f90:39:29:
39 | call bindc_optional(c1, c3)
| 1
internal compiler error: Segmentation fault
0xf57d79 crash_signal(int)
/home/dcb38/gcc/working/gcc/../../trunk.20210101/gcc/toplev.cc:317
0x17bdf2f generic_simplify_COND_EXPR(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*, tree_node*)
/home/dcb38/gcc/working/gcc/generic-match-4.cc:0
0xaecbf8 fold_ternary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*, tree_node*)
Here is a valgrind version of the same gfortran providing some clues:
test $ ~/gcc/results.20240210.valgrind/bin/gfortran -c -w
./Lower/HLFIR/bindc-assumed-length.f90
==3757741== Invalid read of size 2
==3757741== at 0x17793EF: generic_simplify_COND_EXPR(unsigned int,
tree_code, tree_node*, tree_node*, tree_node*, tree_node*)
(generic-match-4.cc:10061)
==3757741== by 0xB082BB: fold_ternary_loc(unsigned int, tree_code,
tree_node*, tree_node*, tree_node*, tree_node*) (fold-const.cc:13144)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113866] ice in generic_simplify_COND_EXPR
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
@ 2024-02-10 17:55 ` kargl at gcc dot gnu.org
2024-02-11 19:01 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2024-02-10 17:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-02-10
Ever confirmed|0 |1
Priority|P3 |P4
Status|UNCONFIRMED |NEW
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
Reduced testcase.
module bindcchar
contains
subroutine bindc_optional(c1, c3) bind(c)
character(*), optional :: c1, c3(100)
print *, c1(1:3), c3(5)(1:3)
end subroutine
subroutine not_bindc_optional(c1, c3)
character(*), optional :: c1, c3(100)
call bindc_optional(c1, c3)
end subroutine
end module
Note, the OPTIONAL attribute is required to cause the ICE.
Note, -Wall generates a few warnings. Perhaps, these should
be errors.
% gfcx -c -Wall fr.f90
fr.f90:5:34:
5 | subroutine bindc_optional(c1, c3) bind(c)
| 1
Warning: Variable ‘c1’ at (1) is a dummy argument of the BIND(C) procedure
‘bindc_optional’ but may not be C interoperable [-Wc-binding-type]
fr.f90:5:38:
5 | subroutine bindc_optional(c1, c3) bind(c)
| 1
Warning: Variable ‘c3’ at (1) is a dummy argument of the BIND(C) procedure
‘bindc_optional’ but may not be C interoperable [-Wc-binding-type]
fr.f90:12:36:
12 | call bindc_optional(c1, c3)
| 1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113866] ice in generic_simplify_COND_EXPR
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
2024-02-10 17:55 ` [Bug fortran/113866] " kargl at gcc dot gnu.org
@ 2024-02-11 19:01 ` anlauf at gcc dot gnu.org
2024-02-12 20:58 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-02-11 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
CC| |anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
Argument passing and the handling of optional arguments differs for bind(c)
procedures from regular ones. For character, the length is not passed as
a hidden argument but in the CFI descriptor.
Tentative partial fix for comment#1:
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 67abca9f6ba..42ef1cd271d 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -7270,7 +7271,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
an intrinsic subroutine, however, fsym is NULL, but we might still
have an optional argument, so we proceed to the substitution
just in case. */
- if (e && (fsym == NULL || fsym->attr.optional))
+ if (e && (fsym == NULL || fsym->attr.optional)
+ && !sym->attr.is_bind_c)
{
/* If an optional argument is itself an optional dummy argument,
check its presence and substitute a null if absent. This is
Likely incomplete; needs checking using variations of dummy and actual args.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113866] ice in generic_simplify_COND_EXPR
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
2024-02-10 17:55 ` [Bug fortran/113866] " kargl at gcc dot gnu.org
2024-02-11 19:01 ` anlauf at gcc dot gnu.org
@ 2024-02-12 20:58 ` anlauf at gcc dot gnu.org
2024-02-13 19:19 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-02-12 20:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
--- Comment #3 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2024-February/060220.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113866] ice in generic_simplify_COND_EXPR
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
` (2 preceding siblings ...)
2024-02-12 20:58 ` anlauf at gcc dot gnu.org
@ 2024-02-13 19:19 ` cvs-commit at gcc dot gnu.org
2024-02-13 21:13 ` anlauf at gcc dot gnu.org
2024-03-29 17:02 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-13 19:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
--- Comment #4 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:f4935df217ad89f884f908f39086b322e80123d0
commit r14-8961-gf4935df217ad89f884f908f39086b322e80123d0
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Feb 13 20:19:10 2024 +0100
Fortran: fix passing of optional dummies to bind(c) procedures [PR113866]
PR fortran/113866
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_procedure_call): When passing an optional
dummy argument to an optional dummy argument of a bind(c) procedure
and the dummy argument is passed via a CFI descriptor, no special
presence check and passing of a default NULL pointer is needed.
gcc/testsuite/ChangeLog:
* gfortran.dg/bind_c_optional-2.f90: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113866] ice in generic_simplify_COND_EXPR
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
` (3 preceding siblings ...)
2024-02-13 19:19 ` cvs-commit at gcc dot gnu.org
@ 2024-02-13 21:13 ` anlauf at gcc dot gnu.org
2024-03-29 17:02 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-02-13 21:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |14.0
--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-14.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113866] ice in generic_simplify_COND_EXPR
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
` (4 preceding siblings ...)
2024-02-13 21:13 ` anlauf at gcc dot gnu.org
@ 2024-03-29 17:02 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-29 17:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:5f9144021615f24d038890dab7db2a0b9e84f6d3
commit r13-8506-g5f9144021615f24d038890dab7db2a0b9e84f6d3
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Feb 13 20:19:10 2024 +0100
Fortran: fix passing of optional dummies to bind(c) procedures [PR113866]
PR fortran/113866
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_procedure_call): When passing an optional
dummy argument to an optional dummy argument of a bind(c) procedure
and the dummy argument is passed via a CFI descriptor, no special
presence check and passing of a default NULL pointer is needed.
gcc/testsuite/ChangeLog:
* gfortran.dg/bind_c_optional-2.f90: New test.
(cherry picked from commit f4935df217ad89f884f908f39086b322e80123d0)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-29 17:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-10 17:31 [Bug fortran/113866] New: ice in generic_simplify_COND_EXPR dcb314 at hotmail dot com
2024-02-10 17:55 ` [Bug fortran/113866] " kargl at gcc dot gnu.org
2024-02-11 19:01 ` anlauf at gcc dot gnu.org
2024-02-12 20:58 ` anlauf at gcc dot gnu.org
2024-02-13 19:19 ` cvs-commit at gcc dot gnu.org
2024-02-13 21:13 ` anlauf at gcc dot gnu.org
2024-03-29 17:02 ` cvs-commit 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).