[Bug c/82050] [8 Regression] ICE on invalid code on x86_64-linux-gnu in column_range, at diagnostic-show-locus.c:1403

dmalcolm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 28 19:25:00 GMT 2017


--- Comment #6 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Author: dmalcolm
Date: Tue Nov 28 19:24:35 2017
New Revision: 255214

URL: https://gcc.gnu.org/viewcvs?rev=255214&root=gcc&view=rev
Reject fix-it hints for various awkward boundary cases (PR c/82050)

PR c/82050 reports a failed assertion deep within diagnostic_show_locus's
code for printing fix-it hints.

The root cause is a fix-it hint suggesting a textual replacement,
where the affected column numbers straddle the LINE_MAP_MAX_COLUMN_NUMBER
boundary, so that the start of the range has a column number, but the
end of the range doesn't.

The fix is to verify that the column numbers are sane when adding fix-it
hints to a rich_location, rejecting fix-it hints where they are not.

        PR c/82050
        * include/line-map.h (LINE_MAP_MAX_COLUMN_NUMBER): Move here.
        * line-map.c (LINE_MAP_MAX_COLUMN_NUMBER): ...from here.
        (rich_location::maybe_add_fixit): Reject fix-it hints in which
        the start column exceeds the next column.


More information about the Gcc-bugs mailing list