Subject: GCC bug?
From: [email-masked] (Tom Uban)

20 Oct 1998 09:31:13 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: [email-masked]

One of the people here has discovered what we believe to be a bug with gcc.
The version I am currently running is:

	gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
	Cygnus b19.1
	Windows95

I plan to update to the latest version pretty soon, but I wanted to make
sure that no major problems cropped up in the gnu-win32 mail group before
I took the time to switch.

The bug is outlined in the code that follows.

Can someone test this on the latest release and let me know if it is still
broken?

--tnx
--tom

------------------------------------------------------------------------------
class test
{
  public:
    test(int a);
    test(int a, char b);

    int mA;
    char mB;

private:             // making this public "fixes" the problem
    test(const test &hack_to_copy);
};

test::test(int a)
{
    mA=a;
}

test::test(int a, char b)
{
    mA=a;
    mB=b;
}

test t1(2);          // this is ok
test t2(2, 'a');     // this is ok
test testarray[]=    
{
    test(3),         // Anything in the array using this type of constructor
    test(4, 'b'),    // generates an error when the copy constructor is
    test(5),         // private.  It works just fine if the copy constructor
    test(6, 'c')     // is not defined or is public.
};

// Apparently, gcc believes it must make a temporary object and then copy
// it into the array.  Other compilers, specifically CAD-UL and Borland
// 4.5 do not reject this array initialization, and by all indications the 
// code is not generating temporary objects under these compilers.  

// In books such as "C++ for Professional Programmers" (by Stephen Blaha,
// Thomson Computer Press) on pg. 121 and "The C++ Programming Language 2nd
// Edition" (by Bjarne Stroustrup, Addison Wesley) on pg. 579, it is
// implied that each object of the array is constructed directly, and that no
// intervening object requiring a public copy constructor is required.  It is
// on that basis, and the fact that the above compilers do not complain about
// the code either, that I believe this to be a bug in gcc.

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".