https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87828

            Bug ID: 87828
           Summary: g++ crashes in sizeof within lambda (ice-on-valid)
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janniksilvanus at gmail dot com
  Target Milestone: ---

: 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.

Reply via email to