[Bug c++/44313] g++ no longer warns about private copy constructors
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 13 03:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44313
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-12-13
Ever confirmed|0 |1
--- Comment #5 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Ian Lance Taylor from comment #0)
> Our very own web page has a C++ FAQ about requires that a copy constructor
> be visible when initializing a const reference:
> http://gcc.gnu.org/bugs/#cxx_rvalbind
>
> However, current versions of gcc do not give an error for that code, even
> when using -pedantic -std=c++98. The last version of gcc to give the error
> was gcc 4.2. This seems ironic considering that we say "most popular
> compilers do not correctly implement this rule."
>
> I think we should give that error when -pedantic.
Confirmed that there is still no error:
$ cat 44313.cc
class A
{
public:
A();
private:
A(const A&); // private copy ctor
};
A makeA(void);
void foo(const A&);
void bar(void)
{
foo(A()); // error, copy ctor is not accessible
foo(makeA()); // error, copy ctor is not accessible
A a1;
foo(a1); // OK, a1 is a lvalue
}
$ /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Weffc++ -std=c++98 44313.cc
$
(silence)
More information about the Gcc-bugs
mailing list