https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88227
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |kargl at gcc dot gnu.org
--- Comment #9 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #8)
> (In reply to kargl from comment #7)
> > (In reply to Dominique d'Humieres from comment #6)
> > > The following test giveS ALSO an ICE with -m32
> > >
> > > % cat boz_10.f90
> > > print *, real(b'1010101001101',10)
> > > end
> > > % gfortran -m32 boz_10.f90
> > > f951: internal compiler error: Segmentation fault: 11
> > > libbacktrace could not find executable to open
> > > Please submit a full bug report,
> > > with preprocessed source if appropriate.
> > > See <https://gcc.gnu.org/bugs/> for instructions.
> >
> > I've thought about this, and think it can be fixed by
> > removing the use gfc_max_integer_kind variable. Simply
> > convert the BOZ to an GMP mpz_t with a suitable width.
> > As I don't use multilib or the precision promoting
> > options I cannot test the change.
>
> In gfortran's current manifestation, it is not possible
> to support BOZ conversion when someone uses a rather
> poor combination of options. The following patch prevents
> the ICE.
>
> Index: check.c
> ===================================================================
> --- check.c (revision 273766)
> +++ check.c (working copy)
> @@ -108,9 +108,8 @@ is_boz_constant (gfc_expr *a)
> bool
> gfc_boz2real (gfc_expr *x, int kind)
> {
> - extern int gfc_max_integer_kind;
> gfc_typespec ts;
> - int len;
> + int i, len;
> char *buf, *str;
>
> if (!is_boz_constant (x))
> @@ -165,6 +164,11 @@ gfc_boz2real (gfc_expr *x, int kind)
> x->boz.str = XCNEWVEC (char, len + 1);
> strncpy (x->boz.str, buf, len);
>
> + i = gfc_validate_kind (BT_REAL, kind, false);
> + if (gfc_real_kinds[i].mode_precision > 8 * gfc_max_integer_kind)
> + gfc_fatal_error ("Insufficient INTEGER kind required "
> + "in BOZ conversion at %L!", &x->where);
> +
> /* Convert to widest possible integer. */
> gfc_boz2int (x, gfc_max_integer_kind);
> ts.type = BT_REAL;
So, I looked at this a little closer, and one does not need
to use any combination of options to invoke the ICE. One
simply needs a 32-bit target (e.g., i586-*-freebsd) target.
gfortran uses the largest possible INTEGER to encode a BOZ.
On i586-*-freebsd, this is INTEGER(8), a 64-bit entity. On
this target, gfortran supports REAL(10) and REAL(16), which
are 80-bit and 128-bit entities.
I have a work in progress for converting a BOZ without the
INTEGER(8) intermediate step.
the BOZ conversion.