[comp.lang.c++] Zortech bugs

srwmrbd@windy.dsir.govt.nz (ROBERT) (02/02/89)

This is a list of examples of things we have found that don't work in
Zortech C++ (1.07) but do work in Advantage/Designer C++  1.2 (beta-2)
on a PC.


Automatic conversions (p174-5) - Compiler returns a bug message (11157) when
   a conversion is required if the conversion is explicitly requested, a
   syntax error if it is not.


#include <stream.hpp>

class APPLES
{
   int napples;
public:
   APPLES() { }
   APPLES(int n) { napples=n; }
   operator int() { return napples; }
};

class ORANGES
{
   int noranges;
public:
   ORANGES(int n) { noranges=n; }
   operator APPLES() { return APPLES(2*noranges); }
};

main()
{
   APPLES a; ORANGES o=7;
   a=(APPLES)o;                        // bug 11157 generated by this line
//   a=o;                              // syntax error generated by this line
   cout << (int)a;
}


A further conversion(?) problem:


#include <stream.hpp>

class A
{
   int data;
public:
   A(int i) { data=i; }
   friend ostream& operator<<( ostream&, A& );
   operator int() { return (int)data; }
};

ostream& operator<<(ostream& o, A& a) { o<<a.data; return o; }

main()
{
   A aa(2);
   cout << aa;                  // this line returns a syntax error
}


A further conversion(?) problem:


#include <stream.hpp>

class V
{
public:
   V(char *);
   friend ostream& operator<<(ostream&, V&);
};

class M : public V
{
public:
   M(char *);
   friend ostream& operator<<(ostream&, M&);
};

main()
{
   cout << "test";                       // syntax error on this line
}




A variety of errors when an 8087 is used with float. There is no problem
if one replaces float by double or disables the 8087.


#include <stream.hpp>

float square(float x)  { return x*x; }

main()
{
   extern int _8087;
   if (_8087) _control87(0x300,0x300);
   cout << "8087 code = " << _8087 << "\n";
//   _8087 = 0;
   float x0=0.00000000000000000000000000000000000001;
   cout << x0 <<" "<< x0*x0 <<" "<< square(x0) <<"\n";
   float x1=0.0000000000000000001;
   cout << x1 <<" "<< x1*x1 <<" "<< square(x1) <<"\n";
   float x2=0.0;
   cout << x2 <<" "<< x2*x2 <<" "<< square(x2) <<"\n";
   float x3=0.00001;
   cout << x3 <<" "<< x3*x3 <<" "<< square(x3) <<"\n";
}


Help file problem

I have all the Zortech files on drive D but carry out development on
drive C. I am unable to access online help from drive C.



Notes: Zortech C++ compiles about 3 times faster than Glockenspiel + MSC 5.1
on my test program and will also handle bigger projects. Speed and codefile
size seem similar if you use the -f flag for Zortech. So, at least at the
development stage of a project on a PC, it is much nicer to use Zortech than
Glockenspiel but it is also frustrating not knowing whether an error is one's
own or Zortech's.


Robert Davies

rchen@m.cs.uiuc.edu (02/06/89)

Zortech C++ didn't handle duplicate const declarations as well, so I
cann't put "const int a = 1;" in the header file.  Otherwise, Zortech
C++ is fine with me so far.

-Ron Chen

maxsmith@athena.mit.edu (Samuel M Druker) (02/08/89)

Use:
static const int i = 10;

Linkage is currently different that cfront.  

tony@banana.cs.uq.oz (Tony O'Hagan) (02/08/89)

In article <4800049@m.cs.uiuc.edu> rchen@m.cs.uiuc.edu writes:
>
>Zortech C++ didn't handle duplicate const declarations as well, so I
>cann't put "const int a = 1;" in the header file.  Otherwise, Zortech
>C++ is fine with me so far.
>
>-Ron Chen

I have a similar problem ...  Zortech won't link multiple object files
created from a header containing a class with static variables.

My guess is that each time you #include the class declaration it's static
variables are defined as local to the object file.  When they get linked
every object file which uses the class thinks it has the original static
variables rather than an extern reference.  Deciding which object file
should contain the real variables sounds like a juicy problem (or a new
version of the linker).

Not being able to have such a class in a header file rather defeats the
purpose of having the class declaration.

Any suggestions or hopes Walter Bright ?

How do Unix implementation get around this ?

	Tony O'Hagan		

P.S.  I'm using ZTC Version 1.04

bright@Data-IO.COM (Walter Bright) (02/09/89)

In article <4800049@m.cs.uiuc.edu> rchen@m.cs.uiuc.edu writes:
<Zortech C++ didn't handle duplicate const declarations as well, so I
<cann't put "const int a = 1;" in the header file.

As a workaround, you can call it:
	static const int a = 1;
The problem is a is made global by default, not static. This will be
fixed in the next version.

bright@Data-IO.COM (Walter Bright) (02/11/89)

In article <2285@uqcspe.cs.uq.oz> tonyo@qitfit.qitcs.oz (Tony O'Hagan) writes:
>I have a similar problem ...  Zortech won't link multiple object files
>created from a header containing a class with static variables.

Declaring the class:
	class abc
	{	static int def = 3;
	};
Will cause multiple definitions (because common blocks cannot have
initializers).
It should be declared as:
	class abc
	{	static int def;
	};
and then in ONE of the modules:
	int abc::def = 3;
However, the int abc::def=3; is not implemented yet, but I will do it
soon.

cszohagan@qut.edu.au (02/14/89)

In my attempts (as yet uncomplete) to tie in the back end of streams i/o
into a <curses.h> type window, I came accross a bug in Zortech's definition
of <stream.hpp>.  The 2nd constructor for streambuf is missing an initialisation
for the variable "FILE* fp".  This causes problems in the sputc() function
below if performing i/o on a buffer (as opposed to a file pointer).

Useful info if you ever get stuck fiddling with the back end of stream i/o
is that doallocate() allocates 1k chunks of memory and sets the alloc flag to 1.

include/stream.hpp
------------------

< streambuf(char* buf, int buflen) { setbuf(buf,buflen); alloc = 0; }

> streambuf(char* buf, int buflen) {
>	setbuf(buf,buflen); alloc = 0;
>	fp = (FILE *) 0;
> }

	Thanks Walter, I'm enjoying C++,
	Tony O'Hagan