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

            Bug ID: 118385
           Summary: A temporary expression bound to a reference member in
                    a mem-initializer is ill-formed
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rush102333 at gmail dot com
  Target Milestone: ---

https://eel.is/c++draft/class.base.init#8:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A temporary expression bound to a reference member in a mem-initializer is
ill-formed.
[Example 5: 

struct A {
  A() : v(42) { }   // error
  const int& v;
};

— end example]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The example above does not trigger the corresponding error in gcc:

https://godbolt.org/z/ao1jMxz69

Reply via email to