https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97009
Bug ID: 97009 Summary: Inlining with non-standard selected_int_kind leads to errors Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: pvitt at posteo dot de Target Milestone: --- Created attachment 49207 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49207&action=edit Minimum working example to reproduce the problem. We ran into a problem that I stripped down to a minimal working example (see attachment). When the MWE is compiled with `gfortran -O1 2269_mwe.f90`, it produces the expected output Level 3 treeID 0 Level 2 treeID 1 Level 1 treeID 9 When it is compiled with O2, it fails: Level 3 treeID 140732851705864 Level 2 treeID 140732851705352 Level 1 treeID 4545064992 When the line integer, parameter :: long_k = selected_int_kind(15) is changed to integer, parameter :: long_k = selected_int_kind(9) it works with O1 and O2. We stumbled over this when some unit tests failed after we activated LTO. Our first guess was that LTO stumbles over the elemental function (which tem_pathOf was before I stripped it down). However, while creating the MWE, we ended up reproducing the behavior also without LTO, but the called function in the same file. And as it disappears with O1, it seems to be related to inlining in general.