public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30959]  New: copy consturctor influences compile errors of constructor from unrelated class
@ 2007-02-25 13:43 sl at datamyway dot de
  2007-02-25 16:50 ` [Bug c++/30959] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: sl at datamyway dot de @ 2007-02-25 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

Depending on whether the copy constructor CA(const CA& a) (see following code)
is private, public or not (explicitly) defined the constructor   CA(const SA&
a) from the unrelated class SA gets compile errors.
It compiles for public and undefined, but not for private.
If CA(const CA& a) is public, the code compiles and runs as expected, and
CA(const CA& a) is not executed (but somehow needed for compilation?!).
---

on SuSe linux 10.0 with
~/wurschtel/cpp> uname -a
Linux djebe 2.6.13-15-smp #1 SMP Tue Sep 13 14:56:15 UTC 2005 i686 i686 i386
GNU/Linux
and gcc 4.0.2 (but also with 4.1.2)
the code (file y.cpp) 
-----
//originally from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478, modified
#include <iostream>
using namespace std;

class SA
{
};

class CA
{
public:
  CA()
  {
    cout << "CA()" << endl;
  };

  CA(const SA& a)
  {
    cout << "CA(const SA& a)" << endl;
  };


private:
  CA(const CA& a)
  {
    cout << "CA(const CA& a)" << endl;
  };


};

void foo(const SA& pa)
{
  const CA ra=CA(pa);
}

int main (int argc, char* argv[])
{
  const SA* pa = new SA();
  const CA pb(*pa);

  foo(*pa);

}


-----
gives compile errors:
g++ -ansi -pedantic -Wall -o y y.cpp
y.cpp: In function â&#128;&#152;void foo(const SA&)â&#128;&#153;:
y.cpp:27: error: â&#128;&#152;CA::CA(const CA&)â&#128;&#153; is private
y.cpp:37: error: within this context
y.cpp:27: error: â&#128;&#152;CA::CA(const CA&)â&#128;&#153; is private
y.cpp:37: error: within this context
slehr@djebe:~/wurschtel/cpp>


-- 
           Summary: copy consturctor influences compile errors of
                    constructor from unrelated class
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sl at datamyway dot de


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


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

* [Bug c++/30959] copy consturctor influences compile errors of constructor from unrelated class
  2007-02-25 13:43 [Bug c++/30959] New: copy consturctor influences compile errors of constructor from unrelated class sl at datamyway dot de
@ 2007-02-25 16:50 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-25 16:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-02-25 16:49 -------
The C++ standard as written requires this error, though the intent of the C++
standards committee was not having this error message.  There was a defect
report against the C++ standards about this error and that is recorded as PR
25950.

*** This bug has been marked as a duplicate of 25950 ***


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-02-25 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-25 13:43 [Bug c++/30959] New: copy consturctor influences compile errors of constructor from unrelated class sl at datamyway dot de
2007-02-25 16:50 ` [Bug c++/30959] " 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).