public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-11441] fortran: Fix ICE on pr96024.f90 on big-endian hosts [PR96024]
@ 2023-06-09 8:01 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-06-09 8:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f46b16ef25fec4f936724ca449259db5c3de0f54
commit r10-11441-gf46b16ef25fec4f936724ca449259db5c3de0f54
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jun 9 09:10:29 2023 +0200
fortran: Fix ICE on pr96024.f90 on big-endian hosts [PR96024]
The pr96024.f90 testcase ICEs on big-endian hosts. The problem is
that length->val.integer is accessed after checking
length->expr_type == EXPR_CONSTANT, but it is a CHARACTER constant
which uses length->val.character union member instead and on big-endian
we end up reading constant 0x100000000 rather than some small number
on little-endian and if target doesn't have enough memory for 4 times
that (i.e. 16GB allocation), it ICEs.
2023-06-09 Jakub Jelinek <jakub@redhat.com>
PR fortran/96024
* primary.c (gfc_convert_to_structure_constructor): Only do
constant string ctor length verification and truncation/padding
if constant length has INTEGER type.
(cherry picked from commit 4cf6e322adc19f927859e0a5edfa93cec4b8c844)
Diff:
---
gcc/fortran/primary.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index 56b05795c27..c12cbe92e85 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -3209,10 +3209,11 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c
goto cleanup;
/* For a constant string constructor, make sure the length is
- correct; truncate of fill with blanks if needed. */
+ correct; truncate or fill with blanks if needed. */
if (this_comp->ts.type == BT_CHARACTER && !this_comp->attr.allocatable
&& this_comp->ts.u.cl && this_comp->ts.u.cl->length
&& this_comp->ts.u.cl->length->expr_type == EXPR_CONSTANT
+ && this_comp->ts.u.cl->length->ts.type == BT_INTEGER
&& actual->expr->ts.type == BT_CHARACTER
&& actual->expr->expr_type == EXPR_CONSTANT)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-09 8:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 8:01 [gcc r10-11441] fortran: Fix ICE on pr96024.f90 on big-endian hosts [PR96024] Jakub Jelinek
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).