www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000188

When Created: 11/10/1997 07:44:38
Against DJGPP version: 2.01
By whom: wrbrooks@hcc-uky.campus.mci.net
Abstract: Conversion of derived to base types by value doesn't work with -freg-struct-return
An undefined value is returned when a derived type D is returned by a
function with a return type that is a base type of D when the flag
-freg-struct-return is turned on.

Here is an example of a program that runs incorrectly using the
flag -freg-struct-return but correctly without it:

#include <iostream.h>

class Base
{
	int value;

public:
	Base() : value(1) { }
	operator int() const { return value; }
};

class Derived : public Base
{
};

class Other
{
	Derived derived;

public:
	operator Base() const { return derived; }
};

main()
{
	cout << Base(Other()) << endl;
}

Note added: 04/13/1999 07:00:03
By whom: eliz@is.elta.co.il
Seems like a GCC bug that has nothing to do with DJGPP.

Closed on 04/13/1999 07:00:39: This is a bug in the C++ compiler.
By whom: eliz@is.elta.co.il



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010