This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/2112: Diagnostic message misleading for binding r-value to non-const reference
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2112: Diagnostic message misleading for binding r-value to non-const reference
- From: richarda at ixla dot com dot au
- Date: 27 Feb 2001 03:12:25 -0000
- Reply-To: richarda at ixla dot com dot au
>Number: 2112
>Category: c++
>Synopsis: Diagnostic message misleading for binding r-value to non-const reference
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 26 19:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Richard Andrews, Ixla Ltd.
>Release: CVS 20010215
>Organization:
>Environment:
i386-pc-linux-gnu (RedHat 6.2)
>Description:
When a function (particularly constructor) takes a
non-const reference argument and a temporary is passed
to it, the compiler generates a diagnostic that the
function signature does not match any prototype.
This is misleading. The problem is that a temporary is being
pass as a non-const reference.
It took me hours to figure the real problem and I consider
my an experienced C++ user.
>How-To-Repeat:
//compile this
struct item
{
item(int i);
int it_;
};
struct thing
{
thing( item & it );
int th_;
};
void doTest()
{
// item i(0);
// thing th( i );
thing th( item(1) ); // passes temporary to constructor
}
>Fix:
Produce correct diagnostic.
>Release-Note:
>Audit-Trail:
>Unformatted: