Hi Tobias, Am 28.03.22 um 12:05 schrieb Tobias Burnus: > Thanks for the patch! LGTM and I think GCC 12 is still okay. > > However, I have a nit: > >> --- a/gcc/fortran/resolve.cc >> +++ b/gcc/fortran/resolve.cc >> @@ -1375,11 +1375,22 @@ resolve_structure_cons (gfc_expr *expr, int init) >> ... >> +           long len_a, len_b; >> +           len_a = mpz_get_si (comp->ts.u.cl->length->value.integer); >> +           len_b = mpz_get_si >> (cons->expr->ts.u.cl->length->value.integer); >> +           gfc_error ("Unequal character lengths (%ld/%ld) for pointer " >> +                      "component %qs in constructor at %L", >> +                      len_a, len_b, comp->name, &cons->expr->where); > > 'long' might be int32_t instead of int64_t (e.g. on Windows, I think both > MinGW32 and MinGW64, but I am not quite sure). Thus, I wonder whether it > makes more sense to use: > >   HOST_WIDE_INT, gfc_mpz_get_hwi() and '%wd' > > I note that '%wd' (and '%lld') is only supported since last August > (commit https://gcc.gnu.org/r12-3044-g1b507b1e3c5 ), but now that it is, > I think we should use it at places where the value can be larger than > INT_MAX. using HOST_WIDE_INT as in the updated patch (sort of) works, but for some reason I do not yet understand the format check kicks in for gfc_error, producing: ../../gcc-trunk/gcc/fortran/resolve.cc: In function 'bool resolve_structure_cons(gfc_expr*, int)': ../../gcc-trunk/gcc/fortran/resolve.cc:1388:43: warning: unknown conversion type character 'w' in format [-Wformat=] la, lb, comp->name, &cons->expr->where); ^ ../../gcc-trunk/gcc/fortran/resolve.cc:1388:43: warning: unknown conversion type character 'w' in format [-Wformat=] ../../gcc-trunk/gcc/fortran/resolve.cc:1388:43: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'long int' [-Wformat=] ../../gcc-trunk/gcc/fortran/resolve.cc:1388:43: warning: format '%L' expects argument of type 'locus*', but argument 3 has type 'long int' [-Wformat=] ../../gcc-trunk/gcc/fortran/resolve.cc:1388:43: warning: too many arguments for format [-Wformat-extra-args] This would likely lead to a bootstrap error. Do I need to add some forgotten include? Or some annotation to suppress the warning? Or should I rather convert the character lengths via sprintf first before generating the error message? (That would be the quick fix.) > I think at some point, we should also check the rest of the code and > change those mpz_get_si to gfc_mpz_get_hwi which can exceed INT_MAX. > Likewise, some of the %ld/%lu or %lld/%llu code should be also converted > to %wd/%wu. > > Tobias > > PS: For using HWI with 'sprintf' instead of diagnostic's error/warning, > HOST_WIDE_INT_PRINT_DEC exists and has to be used. All current cases of printing a HOST_WIDE_INT in gcc/fortran/ use 'sprintf', and I did not find any other use of %wd/%wu. So the mentioned implementation is not really stressed yet... ;-) Thanks, Harald > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, > 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: > Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; > Registergericht München, HRB 106955 >