Is this a bug in egcs or is it egcs better adherence to the standard.

Dan Glastonbury Dan.Glastonbury@adelaide.maptek.com.au
Tue Sep 1 20:22:00 GMT 1998


The following code:
main.C
--
#include "dataengine/Abstract.H"
#include "modelling/PointSet.H"

void 
f(void)
{
  mdlC_PointSet pointSet;
  deC_Abstract<mdlC_PointSetR> pointSetR(pointSet);
  geoS_Point newPoint(0, 0, 0);
  newPoint = pointSetR->P[0];
}

int
main(void)
{
  return 0;
}
--
compiles fine under gcc 2.7.2.1, MSVC++ 5.0, and SGI's CC V7.2. (Well code 
like this) Under gcc-2.8.* and egcs I get the following message.

dan@gauss[~/compiler-bug]> g++ -DPLATFORM_SGI_IRIX -DOS_MAJOR_6 -DOS_MINOR_2 
-I/maptek/people/dan/carmen/include -I/maptek/people/dan/carmen -c main.C
/maptek/people/dan/carmen/include/geometry_new/Point.H: In function `void 
f()':
/maptek/people/dan/carmen/include/geometry_new/Point.H:364: 
`geoC_PointR::operator geoS_Point() const' is from private base class
main.C:10: within this context

If I cast the result, before assignment to newPoint, it works fine.

The deC_Abstract class has an overloaded -> operator:
--
template< class TYPE >
class deC_Abstract
{
public:
 ...
  TYPE* operator->();
 ...
private:
 ...
  TYPE* myCastPointer;
 ...
};
--
The -> operator returns the private member myCastPointer.

I've included bzip2 compressed output of the preprocessor for anyone who is 
interested. (size about 27K)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.ii.bz2
Type: application/x-bzip2
Size: 25440 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19980901/f5fca1ab/attachment.bz2>


More information about the Gcc-bugs mailing list