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

            Bug ID: 115557
           Summary: initializing reference property inside template
                    context - error is not recognized
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nmmm at nmmm dot nu
  Target Milestone: ---

Following code compiles without error or warning.

B::A &a{ 4 }; - this should emit error.

clang catch this and error message is:
non-const lvalue reference to type 'A' cannot bind to an initializer list
temporary



struct A{
    A(int){}
};

template<typename T>
struct B{
    B(A &a) : a(a){}

    A &a{ 4 }; // this is wrong
};

int main(){
    A a{ 5 };

    B<double> b(a);
}

Reply via email to