https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119837
Bug ID: 119837 Summary: Off-by-one truncation in a warning message from gfortran with quoted string Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: kargls at comcast dot net Target Milestone: --- The following code, program foo i = 6Habcdef print *, i end program foo yields % gfcx -std=legacy -Wall -o z a.f90 a.f90:3:7: 3 | i = 6Habcdef | 1 Warning: Conversion from HOLLERITH to INTEGER(4) at (1) [-Wconversion] a.f90:3:7: 3 | i = 6Habcdef | 1 Warning: The Hollerith constant at (1) is truncated in conversion to 'INTEGER(4' [-Wcharacter-truncation] Notice that that the second warning truncates the type name to 'INTEGER(4'. That is, it is missing the closing parenthesis. This warning comes from misc.cc(hollerith2representation) if (src_len > result_len) { gfc_warning (OPT_Wcharacter_truncation, "The Hollerith constant at %L " "is truncated in conversion to %qs", &src->where, gfc_typename(&result->ts)); } I checked and gfc_typename(&result->ts) returns INTEGER(4) with the closing parenthesis. That is, if I change the warning to gfc_warning (OPT_Wcharacter_truncation, "The Hollerith constant at %L " "is truncated in conversion to an %qs type", &src->where, gfc_typename(&result->ts)); the printed warning is Warning: The Hollerith constant at (1) is truncated in conversion to an 'INTEGER(4)' type [-Wcharacter-truncation] I also get the correct type name if I change %qs to simply %s. So, the issue appears to be in gfc_warning when the last part of the warning string is %qs.