https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103413
--- Comment #12 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Wed, Oct 26, 2022 at 06:24:04PM +0000, anlauf at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103413 > > --- Comment #11 from anlauf at gcc dot gnu.org --- > (In reply to kargl from comment #10) > > Well, a boz is typeless, so it cannot be compatible with any other type. > > So, I would assume, you could do > > > > if (ts1->type == BT_BOZ || ts2->type == BT_BOZ) > > return false; > > Yes, that's better. > > > There is a caveat in that Fortran 2023 is going to allow > > things like > > > > real :: x = z'1234' > > > > if gfc_type_compatible is used in simple assignments, gfortran will > > need to deal with that. > > It is currently not used in those cases. Hmmm, I wonder if there is duplicate code within gfortran that re-implements gfc_type_compatible. If time permits, I'll see what comes with a grep of "->type == *->type". > The following is already rejected: > > program p > real :: r > data r / z'1234' / > r = z'1234' > print *, r > end > > pr103413-boz.f90:3:18: > > 3 | data r / z'1234' / > | 1 > Error: BOZ literal constant near (1) cannot be assigned to a REAL variable > [see > '-fno-allow-invalid-boz'] F2018 If a data-stmt-constant is a boz-literal-constant, the corresponding variable shall be of type integer. F2023 is unchanged. > pr103413-boz.f90:4:6: > > 4 | r = z'1234' > | 1 > Error: BOZ literal constant at (1) is neither a DATA statement value nor an > actual argument of INT/REAL/DBLE/CMPLX intrinsic subprogram [see > '-fno-allow-invalid-boz'] This I need to look up in F2023. The statement may be allowed only in an initialization expression. > Interestingly, -fno-allow-invalid-boz is not an allowed option... > But even when using -fallow-invalid-boz, which degrades the above > to a warning, I never get to gfc_type_compatible. The lack of -fno-allow-invalid-boz was intentional. A BOZ in an invalid context is an error. -fallow-invalid-boz allows that invalid context, but issues a warning. The only way to disable the warning is with -w (ie., you disable all warnings).