public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36393]  New: Copy constructor not used but required
@ 2008-05-30 19:30 peter dot klotz at aon dot at
  2008-08-11  2:15 ` [Bug c++/36393] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: peter dot klotz at aon dot at @ 2008-05-30 19:30 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

The following code compiles with gcc 3.2.3 and the current Comeau compiler.
However it fails with gcc 4.1.2 and gcc 4.2.3.

class A
{
public:
    A(bool) {};
private:
    A(const A&);
};

class B
{
public:
    B(const A&) {};
};

int main(void)
{
    B b(A(true));
    return 0;
}

Gives this error message:

test.cpp: In function ‘int main()’:
test.cpp:6: error: ‘A::A(const A&)’ is private
test.cpp:17: error: within this context

I don't see where the code above would need a copy constructor for class A.
Making the copy constructor of A public without implementing it makes the code
compile.


-- 
           Summary: Copy constructor not used but required
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: peter dot klotz at aon dot at
  GCC host triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/36393] Copy constructor not used but required
  2008-05-30 19:30 [Bug c++/36393] New: Copy constructor not used but required peter dot klotz at aon dot at
@ 2008-08-11  2:15 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-11  2:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-08-11 02:14 -------
>When binding an rvalue of class type to a reference, the copy constructor of the class must be accessible. For instance, consider the following code:

>From http://gcc.gnu.org/gcc-3.4/changes.html


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-11  2:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-30 19:30 [Bug c++/36393] New: Copy constructor not used but required peter dot klotz at aon dot at
2008-08-11  2:15 ` [Bug c++/36393] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).