[Bug c++/15079] New: Temporary pass by reference should not need copy ctor

david dot lee at teracruz dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 22 21:38:00 GMT 2004


The following code used to compile with gcc 3.3.  It 3.4 emits an error.

[dlee@lindb1 cpp]$ cat nocopy.cpp 
class Foo
{
  public:
    Foo(int) {}
  private:
    Foo(Foo const &);
    Foo&operator=(Foo const &);
};

void foobar(Foo const &);

int main()
{
  Foo const a(0);
  foobar(a);
  foobar(Foo(0)); // nocopy.cpp:6: error: `Foo::Foo(const Foo&)' is private
                  // nocopy.cpp:16: error: within this context
}

[dlee@lindb1 cpp]$ i686-linux-g++ nocopy.cpp -o /dev/null 
nocopy.cpp: In function `int main()':
nocopy.cpp:6: error: `Foo::Foo(const Foo&)' is private
nocopy.cpp:16: error: within this context

-- 
           Summary: Temporary pass by reference should not need copy ctor
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: david dot lee at teracruz dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux
  GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15079



More information about the Gcc-bugs mailing list