https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110565
Bug ID: 110565 Summary: Incomplete note on why initializing int& with int is ill-formed Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blubban at gmail dot com Target Milestone: --- struct X { X(int&); X(X&&) = delete; // the issue reproduces without this line, but the error is clearer with it }; template<int> void f() { new X(0); } Expected output: <source>: In function 'void f()': <source>:8:12: error: no matching function for call to 'X::X(int)' 8 | new X(0); | ^ <source>:2:5: note: candidate: 'X::X(int&)' (near match) 2 | X(int&); | ^ <source>:2:5: note: conversion of argument 1 would be ill-formed: <source>:8:11: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' Actual output: <source>: In function 'void f()': <source>:8:12: error: no matching function for call to 'X::X(int)' 8 | new X(0); | ^ <source>:2:5: note: candidate: 'X::X(int&)' (near match) 2 | X(int&); | ^ <source>:2:5: note: conversion of argument 1 would be ill-formed: The template and new-expression are necessary; the error is proper without them. https://godbolt.org/z/c1Er5nsjd