Bug 87828 - [7 Regression] g++ crashes in sizeof within lambda (ice-on-valid)
Summary: [7 Regression] g++ crashes in sizeof within lambda (ice-on-valid)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.3.1
: P2 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, diagnostic, ice-on-valid-code
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2018-10-31 11:21 UTC by Jannik Silvanus
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.4.0, 8.2.0, 9.0
Known to fail: 7.3.0, 7.5.0
Last reconfirmed: 2018-10-31 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Silvanus 2018-10-31 11:21:51 UTC
: g++-7 --version
g++-7 (SUSE Linux) 7.3.1 20180817 [gcc-7-branch revision 263612]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO                            
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                           

: cat test.ii

struct Test {
   Test();
   Test(Test &);
   int getint();
};

template <typename Applier>
void call_applier(Applier && f) {
   f(int());
}

Test run() {
   Test test;
   call_applier([=](auto) {
      sizeof(test.getint());
   });
   return test;
}


: g++-7 -std=c++1z -Wmissing-format-attribute -c test.ii
test.ii: In instantiation of ‘run()::<lambda(auto:1)> [with auto:1 = int]’:                           
test.ii:9:5:   required from ‘void call_applier(Applier&&) [with Applier = run()::<lambda(auto:1)>]’  
test.ii:16:5:   required from here
test.ii:15:25: internal compiler error: Segmentation fault
       sizeof(test.getint());
             ~~~~~~~~~~~~^~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.

Note the weird -Wmissing-format-attribute flag which is required to trigger the crash, although it seems to be completely unrelated.
Comment 1 Martin Liška 2018-10-31 11:31:33 UTC
Confirmed, only GCC-7 branch is affected. Fixed on trunk in r236615.
Comment 2 Richard Biener 2019-11-14 11:33:34 UTC
Fixed in GCC 8.