tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* CXX question
@ 1997-11-04  7:35 Rainer Schwierz
  0 siblings, 0 replies; only message in thread
From: Rainer Schwierz @ 1997-11-04  7:35 UTC (permalink / raw)
  To: tru64-unix-managers

Hallo DIGITAL UNIX gurus,

first I must say, that I'm not a C++ expert, but our students have
problems with a software package, which compiles without problems on IBM,
HP and SUN Workstations under vendor compilers but does not compile on
DIGITAL's CXX.
I'm using CXX version 5.5 under DU4.0b. (BTW: CXX5.6 shows similar output)

May be that there are problems with pointers to _elementfunctions_.
Here are some examples of one of our students to demonstrate the errors:

******** simple1.cc ******************************************************

class A
{

public:
  typedef int (A:: *Ptr)(void);

  A () { bar (foo); }

  int foo (void);
  void bar (Ptr p);

};

======== cxx -c simple1.cc ===============================================

cxx: Error: simple1.cc, line 8: In this statement, member "A::foo" is
referenced without an object.
  A () { bar (foo); }
--------------^


******** simple2.cc ******************************************************

class A
{

public:
  typedef int (A:: *Ptr)(void);

  A () { bar (this->foo); }

  int foo (void);
  void bar (Ptr p);

};

======== cxx -c simple2.cc ===============================================

cxx: Warning: simple2.cc, line 8: In this statement, "this->foo" refers to
a member function in a context other than as the target of an invocation.
  A () { bar (this->foo); }
--------------^
cxx: Error: simple2.cc, line 8: In this statement, "this->foo" is of type
"pointer to function () returning int", and may not be converted to
"pointer to function () returning int member of A".
  A () { bar (this->foo); }
--------------^


******** simple3.cc ******************************************************

class A
{

public:
  typedef int (A:: *Ptr) (void);

  Ptr foo;
  Ptr function (void);

  Ptr bar (void) { return (foo != 0) ? foo : function (); }

};

======== cxx -c simple3.cc ===============================================

cxx: Error: simple3.cc, line 11: In this statement, "foo" and "function()"
may not be combined in a conditional expression.
  Ptr bar (void) { return (foo != 0) ? foo : function (); }
--------------------------^


******** simple4.cc ******************************************************

class A
{

public:
  typedef int (A:: *Ptr)(void);

  Ptr foo;

  Ptr bar (void) { if (foo) return foo; else return 0; }

};

======== cxx -c simple4.cc ===============================================

cxx: Error: simple4.cc, line 10: The controlling expression "foo" has a
pointer to member type, which is not scalar.
  Ptr bar (void) { if (foo) return foo; else return 0; }
-----------------------^

Note, on AIX4.2 these little programms compile without errors.
Any help will be wellcome.
   Thanks in advance and have a nice day,
            Rainer


| R.Schwierz@physik.tu-dresden.de                     |
| Rainer  Schwierz, Inst. f. Kern- und Teilchenphysik |
| TU Dresden,       D-01062 Dresden                   |
| Tel. ++49 351 463 2957      FAX ++49 351 463 3114   |
| http://hep.phy.tu-dresden.de/~schwierz/             | 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-11-04  7:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-11-04  7:35 CXX question Rainer Schwierz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox