[Bug c++/14774] New: inaccessible unused copy constructor diagnostic could be more helpful
mdorey at bluearc dot com
gcc-bugzilla@gcc.gnu.org
Mon Mar 29 17:36:00 GMT 2004
Compiling:
void h ();
struct B {
private:
B (B&) {
h ();
}
};
struct A {
A ();
B b;
};
void f (const A&);
void g () {
f (A ());
}
Results in:
uncopyable-output-functor.cpp: In function `void g()':
uncopyable-output-functor.cpp:19: error: no matching function for call to
`A::A(const A&)'
uncopyable-output-functor.cpp:10: note: candidates are: A::A(A&)
With:
gcc version 3.4.0 20040320 (prerelease) (Debian)
According to the Standard, section 8.5.3.5, first "Otherwise" clause, this is
correct behaviour. Whether a copy is taken or whether a reference is bound to
the temporary is implementation-defined (why?) and the copy constructor is
required to be accessible whether or not the copy is actually done.
Requiring the accessibility of a function that's not going to be called (and
isn't in this case) seems a sufficiently uncommon and odd case to me that
perhaps a specific diagnostic would reduce confusion? I, for one, nearly
submitted a "this is a regression!" bug.
--
Summary: inaccessible unused copy constructor diagnostic could be
more helpful
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mdorey at bluearc dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14774
More information about the Gcc-bugs
mailing list