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

            Bug ID: 88554
           Summary: Segfault ICE when falling off the end of a
                    reference-returning friend operator
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

struct X {
        friend X& operator+=(X&, int) { }
    };

https://godbolt.org/z/17PLVW
<source>: In function 'X& operator+=(X&, int)':
<source>:3:37: internal compiler error: Segmentation fault
    3 |     friend X& operator+=(X&, int) { }
      |                                     ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

I assume GCC is trying to give a helpful diagnostic about the missing `return`
statement and following a null pointer in the process. Changing the name of the
friend function from `operator+=` to `foo` makes the segfault disappear.

This is happening in trunk but not in GCC 8.2, so it must be a very recent
regression.

Reply via email to