Thread View: net.lang.c++
3 messages
3 total messages
Started by Gene Dykes
Thu, 19 Jun 1986 14:43
Cornell Bug Report #0 of 4
Author: Gene Dykes
Date: Thu, 19 Jun 1986 14:43
Date: Thu, 19 Jun 1986 14:43
68 lines
2912 bytes
2912 bytes
Here at Cornell, it appears that C++ will play a major role in
the development of software that will be shared over the campus-wide
network (TheoryNet). I have used it to write a menu manager, and it
sure made the task easier. I love it! However...
I have a few bugs to report that I don't think have been posted
yet (to be sent in three separate articles), a few bugs that are probably
well known (to be described at the end of this article) and a gripe or
two (to be discussed now).
Gripe #1:
The form() function only takes 8 arguments, which is bad, and that fact
is undocumented (I think), which is worse. The fix is trivial, but I
did spend several hours trying to figure out why some of my output was
mangled until I discovered the problem.
Gripe #2:
It seems that I am always needing to declare a function in one class
as the friend of another class, while also needing to declare a function
in the second class as a friend in the first. C++ squawks because it
needs to have the class defined before it can have a function in it
declared as a friend in another class. Needless to say, it is impossible
to declare each class before the other. So...
1) Does this indicate lousy programming practices on my part?
2) Do lots of other people also run into this?
3) Is there a way to do this that I haven't figured out?
4) Is this something that can't be helped or is a fix on the way?
- - - - - - - - - - - -
Probable well-known bugs
- - - - - - - - - - - -
% cat bug.c
#include <CC/stream.h>
main ()
{
cerr << "works\n" ;
}
% CC bug.c -o bug
CC bug.c:
cc bug..c -o bug -lC
cc: warning: -o ignored when -c or -S used
% bug
works
% CC -c bug.c
CC bug.c:
cc -c bug..c -lC
% cc bug.o -o bug -lC
% bug
Bus error (core dumped)
- - - - - - - - - - - - -
Two problems are revealed by this simple example:
1) a program cannot be compiled by CC and loaded by cc
2) the ridiculous warning that always appears during a CC load
I assume these two problems are well known. If not, there must be something
wrong here, and I would appreciate somebody letting me know what they are...
--
Gene Dykes, 120 Rand Hall, Cornell U., Ithaca, NY 14853 (607)255-6713
{ihnp4,decvax,allegra,vax135}!cornell!batcomputer!gdykes
Re: Cornell Bug Report #0 of 4
Author: cmc
Date: Tue, 24 Jun 1986 20:48
Date: Tue, 24 Jun 1986 20:48
34 lines
1978 bytes
1978 bytes
In article <498@batcomputer.TN.CORNELL.EDU> gdykes@batcomputer.UUCP (Gene Dykes) writes: >... >% CC -c bug.c >CC bug.c: >cc -c bug..c -lC > >% cc bug.o -o bug -lC >% bug >Bus error (core dumped) > >... > > 1) a program cannot be compiled by CC and loaded by cc > The problem arises if your C++ program uses static constructors and/or destructors. A big problem with such programs is that the compiler has to insert a call to a special routine which calls all of the constructors *before* the program starts executing for proper. This cannot be done during the initial compiling stage as the compiler cannot know what constructors will be called from other modules, e.g. the constructors for the standard streams (cout, cin, cerr) in libC.a. The solution used depends on whether you are working on a system with libld.a. If you are, a program called patch is used to build a list of pointers to static constructors and patch it into the executable, On other systems nm(1) is run on the executable and the output piped into a special program called munch. This spots symbols which are static constructors and generates a C file which is then compiled and the whole executable is relinked (now you see why compiling/linking can take an age!) The reason your program bus errored is that the stream package is not being initialised. Chris.
Re: Cornell Bug Report #0 of 4
Author: m.terribile
Date: Wed, 25 Jun 1986 19:11
Date: Wed, 25 Jun 1986 19:11
53 lines
2628 bytes
2628 bytes
> Gripe #2:
> It seems that I am always needing to declare a function in one class
> as the friend of another class, while also needing to declare a function
> in the second class as a friend in the first. C++ squawks because it
> needs to have the class defined before it can have a function in it
> declared as a friend in another class. Needless to say, it is impossible
> to declare each class before the other. So...
> 1) Does this indicate lousy programming practices on my part?
> 2) Do lots of other people also run into this?
> 3) Is there a way to do this that I haven't figured out?
> 4) Is this something that can't be helped or is a fix on the way?
My personal opinions:
No, it's not lousy programming practice. I just missed it, and I
thought it was legal. In fact it's not -- the example below fails as
indicated, and I think that it addresses a rather common problem.
Is there a way around it? Yes. It's ugly as sin and not half as
much fun. You should be able to declare the entire second class as a friend
of the first. ``friend class c2;''
As far is there being a possible fix ... I think that we have to
ask Bjarne. I'd like to see it work in the obvious way. If it can't be
done for all member functions, then I'd like to see it at least work for
constructors (see the example). I suspect that the fix will involve adding
another hyperfine level of sophistication to cfront, but I don't know, not
having studied cfront.
class c2; // c1 and c2 are alternate representations ... one is packed
// for storage and one is unpacked for reasonable coding usage.
// Much stuff omitted ...
class c1
{
public:
c1( c2 ); // This is legal.
friend c2::c2( c1 ); // This is not!
};
class c2
{
public:
c2( c1 );
friend c1::c1( c2 );
};
--
from Mole End Mark Terribile
(scrape .. dig ) mtx5b!mat
(Please mail to mtx5b!mat, NOT mtx5a!
mat, or to mtx5a!mtx5b!mat)
,.. .,, ,,, ..,***_*.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads