Bug 79886 - [6 Regression] ICE in pp_format, at pretty-print.c:681
Summary: [6 Regression] ICE in pp_format, at pretty-print.c:681
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 6.5
Assignee: Jakub Jelinek
URL:
Keywords: diagnostic, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-03-06 08:04 UTC by Martin Liška
Modified: 2018-07-16 10:54 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-03-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-03-06 08:04:42 UTC
Starting from r217383 we ICE:

$ gfortran /home/marxin/Programming/gcc/gcc/testsuite/gfortran.fortran-torture/compile/pr26806.f90 -Wpadded
f951: Warning: padding struct size to alignment boundary [-Wpadded]
f951: Warning: padding struct size to alignment boundary [-Wpadded]
‘
in pp_format, at pretty-print.c:681
0x1478169 pp_format(pretty_printer*, text_info*)
	../../gcc/pretty-print.c:681
0x146a9f8 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
	../../gcc/diagnostic.c:961
0x146ad53 diagnostic_impl
	../../gcc/diagnostic.c:1084
0x146b0cc warning(int, char const*, ...)
	../../gcc/diagnostic.c:1172
0xc5a315 place_field(record_layout_info_s*, tree_node*)
	../../gcc/stor-layout.c:1215
0xc5bafa layout_type(tree_node*)
	../../gcc/stor-layout.c:2375
0x7d4a66 gfc_finish_type(tree_node*)
	../../gcc/fortran/trans-types.c:2251
0x7acb43 gfc_build_st_parameter
	../../gcc/fortran/trans-io.c:222
0x7acb43 gfc_build_io_library_fndecls()
	../../gcc/fortran/trans-io.c:318
0x765c17 gfc_build_builtin_function_decls()
	../../gcc/fortran/trans-decl.c:3771
0x73b71a gfc_create_decls
	../../gcc/fortran/f95-lang.c:189
0x73b71a gfc_be_parse_file
	../../gcc/fortran/f95-lang.c:203
Comment 1 Manuel López-Ibáñez 2017-03-06 08:14:59 UTC
This is probably a warning from the middle end with a printf %-code not
supported by the Fortran FE's pretty printer. The solution is to either add
support for it in the FE or switch to the middle end pp when entering the
middle end. There are several bugs like this one. Another solution is to
either not call into the middle end at arbitrary points during parsing
 only during gimplification (not sure if this is the case here) or move the
warning to the FE (middle end warnings should be avoided if possible).

On 6 Mar 2017 8:04 a.m., "marxin at gcc dot gnu.org" <
gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79886
>
>             Bug ID: 79886
>            Summary: [5/6/7 Regression] ICE in pp_format, at
>                     pretty-print.c:681
>            Product: gcc
>            Version: 7.0
>             Status: UNCONFIRMED
>           Keywords: ice-on-valid-code
>           Severity: normal
>           Priority: P3
>          Component: fortran
>           Assignee: unassigned at gcc dot gnu.org
>           Reporter: marxin at gcc dot gnu.org
>                 CC: manu at gcc dot gnu.org
>   Target Milestone: ---
>
> Starting from r217383 we ICE:
>
> $ gfortran
> /home/marxin/Programming/gcc/gcc/testsuite/gfortran.
> fortran-torture/compile/pr26806.f90
> -Wpadded
> f951: Warning: padding struct size to alignment boundary [-Wpadded]
> f951: Warning: padding struct size to alignment boundary [-Wpadded]
> ‘
> in pp_format, at pretty-print.c:681
> 0x1478169 pp_format(pretty_printer*, text_info*)
>         ../../gcc/pretty-print.c:681
> 0x146a9f8 diagnostic_report_diagnostic(diagnostic_context*,
> diagnostic_info*)
>         ../../gcc/diagnostic.c:961
> 0x146ad53 diagnostic_impl
>         ../../gcc/diagnostic.c:1084
> 0x146b0cc warning(int, char const*, ...)
>         ../../gcc/diagnostic.c:1172
> 0xc5a315 place_field(record_layout_info_s*, tree_node*)
>         ../../gcc/stor-layout.c:1215
> 0xc5bafa layout_type(tree_node*)
>         ../../gcc/stor-layout.c:2375
> 0x7d4a66 gfc_finish_type(tree_node*)
>         ../../gcc/fortran/trans-types.c:2251
> 0x7acb43 gfc_build_st_parameter
>         ../../gcc/fortran/trans-io.c:222
> 0x7acb43 gfc_build_io_library_fndecls()
>         ../../gcc/fortran/trans-io.c:318
> 0x765c17 gfc_build_builtin_function_decls()
>         ../../gcc/fortran/trans-decl.c:3771
> 0x73b71a gfc_create_decls
>         ../../gcc/fortran/f95-lang.c:189
> 0x73b71a gfc_be_parse_file
>         ../../gcc/fortran/f95-lang.c:203
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 2 Jakub Jelinek 2017-03-06 21:04:13 UTC
I wouldn't call layout_type a middle-end, rather a helper shared by all FEs.
It would be best if the Fortran formatters were limited only to the Fortran specific diagnostic functions (gfc_*) and error/error_at/warning_at etc. just used the standard formatters.
Comment 3 Manuel López-Ibáñez 2017-03-07 00:26:57 UTC
Perhaps Fortran FE formatters can call the standard formatters if an
unknown directive is found? I don't know how C/C++ handles this case (does
it support this %-directive or does it switch to the standard pretty
printer?) but there is no reason to not do the same and share the code if
possible.
Comment 5 Manuel López-Ibáñez 2017-03-08 16:59:10 UTC
The first one seems the right approach. It will also fix a number of
similar bugs in one go.The second one seems more fragile and it doesn't
help in decoupling ME from FE more than the first.
Comment 6 Jakub Jelinek 2017-03-16 16:27:40 UTC
Author: jakub
Date: Thu Mar 16 16:27:08 2017
New Revision: 246203

URL: https://gcc.gnu.org/viewcvs?rev=246203&root=gcc&view=rev
Log:
	PR fortran/79886
	* tree-diagnostic.c (default_tree_printer): No longer static.
	* tree-diagnostic.h (default_tree_printer): New prototype.
fortran/
	* error.c (gfc_format_decoder): Rename plus argument to set_locus,
	remove ATTRIBUTE_UNUSED from all arguments, call default_tree_printer
	if not a Fortran specific spec.
	* trans-io.c: Include options.h.
	(gfc_build_st_parameter): Temporarily disable -Wpadded around layout
	of artificial IO data structures.
testsuite/
	* gfortran.dg/pr79886.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr79886.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/error.c
    trunk/gcc/fortran/trans-io.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-diagnostic.c
    trunk/gcc/tree-diagnostic.h
Comment 7 Jakub Jelinek 2017-03-16 16:28:09 UTC
Fixed on the trunk so far.
Comment 8 Jakub Jelinek 2017-10-10 13:28:15 UTC
GCC 5 branch is being closed
Comment 9 Thomas Koenig 2018-02-01 19:50:53 UTC
Any plans to backport to gcc-6?

If not, I think we can close this.
Comment 10 Jürgen Reuter 2018-07-16 09:55:10 UTC
(In reply to Thomas Koenig from comment #9)
> Any plans to backport to gcc-6?
> 
> If not, I think we can close this.

Doesn't look like. Also, I would suspect that there would be at maximum one final revision of gcc-6 and then it will go out of support? 
So, if backporting to gcc-6 is the only open issue, and nobody is doing it (which I don't really see much urgency for), I'd close this PR.
Comment 11 Thomas Koenig 2018-07-16 10:54:16 UTC
So let‘s close this.