This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/3471: gcc 3.01 reports error about a private copy constructor that shouldn't get called.



>Number:         3471
>Category:       c++
>Synopsis:       gcc 3.01 reports error about a private copy constructor that shouldn't get called.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 28 22:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Eric Peterson
>Release:        gcc version 3.0.1 20010627 (prerelease)
>Organization:
>Environment:
debian linux 2.4.0 on i686
>Description:
gnu c++ compiler returns errors on the f.test and f.test2
calls claiming that the copy constructor needs to be
called but is private.  however, foo::foo(bar x)
should be the only constructor that needs to be called in
both cases.

I also confirmed that if you instead modify the foo class
to have a public copy constructor (no compiler error)
that it actually doesn't get called.  So this looks like a
bogus constructor namespace check (since the copy
constructor shouldn't and doesn't get called in the end
anyways).

error message:
$c++ privconstr.C
privconstr.C: In function `int main()':
privconstr.C:5: `foo::foo(const foo&)' is private
privconstr.C:20: within this context
privconstr.C:20:   initializing argument 1 of `void foo::test(const foo&)' from 
   result of `foo::foo(bar)'
privconstr.C:5: `foo::foo(const foo&)' is private
privconstr.C:21: within this context
privconstr.C:21:   initializing argument 1 of `void foo::test2(foo)' from 
   result of `foo::foo(bar)'
>How-To-Repeat:
run:
c++ privconstr.C
>Fix:
make private copy constructor declarations public but
don't define them so their use will at least trigger
a link error
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="privconstr.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="privconstr.C"

Y2xhc3MgYmFyIHsKfTsKCmNsYXNzIGZvbyB7ICAKICBmb28gKGNvbnN0IGZvbyAmZik7CgpwdWJs
aWM6CiAgCiAgZm9vIChiYXIgeCkge30KICBmb28gKCkge30KICAKICB2b2lkIHRlc3QgKGNvbnN0
IGZvbyAmZikge30KICB2b2lkIHRlc3QyIChmb28gZikge30KfTsKCmludCBtYWluICh2b2lkKSB7
CiAgZm9vIGY7CiAgYmFyIGI7CgogIGYudGVzdCAoYik7CiAgZi50ZXN0MiAoYik7CgogIHJldHVy
biAwOwp9Cg==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]