Message ID | 75946d6e-4207-cd5e-a51a-c40ccb39db2a@netcologne.de |
---|---|
State | New |
Headers | show |
Series | [fortran] Fix PR 82743, warning for truncation on constructors | expand |
On Tue, Jan 01, 2019 at 07:42:14PM +0100, Thomas Koenig wrote: > > first of all, Happy New Year to everybody! > > In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all. > > Here is a first contribution towards reaching something similar, or even > better, for 2019. It is a rather straightforward patch which adds a > missing warning for truncated strings in constructors. > > Regression-tested. OK for trunk? > > Regards > > Thomas > > 2019-01-01 Thomas Koenig <tkoenig@gcc.gnu.org> > > PR fortran/82743 > * primary.c (gfc_convert_to_structure_constructor): If a character > in a constructor is too long, add a warning with > -Wcharacter-truncation. > > 2019-01-01 Thomas Koenig <tkoenig@gcc.gnu.org> > > PR fortran/82743 > * gfortran.dg/structure_constructor_16.f90: New test. Looks good to me. Thanks for the patch.
On Tue, Jan 01, 2019 at 07:42:14PM +0100, Thomas Koenig wrote: > > In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all. > Unfortunately, 468 bugs were submitted in 2018. We need to get new and additional eyes looking at the source. I don't know how we do this as efforts in c.l.f to encourage others to step are typically met with "I don't know C".
Index: primary.c =================================================================== --- primary.c (Revision 267335) +++ primary.c (Arbeitskopie) @@ -3074,6 +3074,12 @@ gfc_convert_to_structure_constructor (gfc_expr *e, actual->expr->value.character.length = c; actual->expr->value.character.string = dest; + + if (warn_line_truncation && c < e) + gfc_warning_now (OPT_Wcharacter_truncation, + "CHARACTER expression will be truncated " + "in constructor (%ld/%ld) at %L", (long int) c, + (long int) e, &actual->expr->where); } }