Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Andrew Stewart
Tue, 01 Aug 1989 16:27
Possible bug with Enumeration types
Author: Andrew Stewart
Date: Tue, 01 Aug 1989 16:27
Date: Tue, 01 Aug 1989 16:27
172 lines
3775 bytes
3775 bytes
GNU C++ version: 1.35.0
Compiled with command: g++ -v -g
Files for tm.h and md: tm-sun3.h, m68k.md
Machine: SUN-3, SUNOS 3.5
Behaviour:
Suppose you define an enumerated type of form:
typedef enum { ... } X;
then define a method of the form
class C {
public:
...
void Method(X);
...
};
This is now compiled and stored in a library, with the enumerated type in a
header file for use by an application program.
Now: suppose that when you compile the application program, you define
another enumerated type BEFORE the enumerated type that is used by the
class C (by including another header file, for example).
From the loader, you get something like:
xmain.o: Undefined symbol _Method_PSC_E$_1 referenced from text
I have appended the program that induces the error - if you compile x.cc
and stuff it into a library, swap the two "enum" definitions around and
compile xmain.c you get the error message.
This feels rather like a bug.
Andrew
--------------------
Andrew Stewart, Interactive Systems Design Group, University of Hull, Hull, UK
ARPA: andrew@cs.hull.ac.uk Telephone: +44 482 465744
JANET: andrew@uk.ac.hull.cs Fax: +44 482 466666
UUCP: ..!ukc!hu-cs!andrew
-------------------------- cut here -------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# x.h
# x.cc
# xmain.cc
# This archive created: Tue Aug 1 17:25:48 1989
# By: Andrew Stewart ()
export PATH; PATH=/bin:$PATH
echo shar: extracting "'x.h'" '(315 characters)'
if test -f 'x.h'
then
echo shar: will not over-write existing file "'x.h'"
else
sed 's/^X//' << \SHAR_EOF > 'x.h'
Xtypedef enum
X{
X Four, Five, Six
X} KeyEventTwo;
X
Xtypedef enum
X{
X One, Two, Three
X} KeyEvent;
X
Xclass First
X{
X friend class Second;
X
X int a,b,c;
X
X First();
X ~First();
X void yap();
X void yap(KeyEvent);
X};
X
Xclass Second
X{
X int d,e,f;
X class First *g;
X
Xpublic:
X Second();
X ~Second();
X void zap();
X void zap(KeyEvent);
X};
SHAR_EOF
fi # end of overwriting check
echo shar: extracting "'x.cc'" '(371 characters)'
if test -f 'x.cc'
then
echo shar: will not over-write existing file "'x.cc'"
else
sed 's/^X//' << \SHAR_EOF > 'x.cc'
X#include <stream.h>
X#include "x.h"
X
XFirst::First()
X{
X a = b = c = 1;
X}
X
XFirst::~First()
X{
X}
X
Xvoid First::yap()
X{
X cout << "yap!\n";
X}
X
Xvoid First::yap(KeyEvent ev)
X{
X cout << (int) ev << " yap!\n";
X}
X
XSecond::Second()
X{
X d = e = f = 1;
X g = new First;
X}
X
XSecond::~Second()
X{
X delete g;
X}
X
Xvoid Second::zap()
X{
X g->yap();
X}
X
Xvoid Second::zap(KeyEvent ev)
X{
X g->yap(ev);
X}
SHAR_EOF
fi # end of overwriting check
echo shar: extracting "'xmain.cc'" '(170 characters)'
if test -f 'xmain.cc'
then
echo shar: will not over-write existing file "'xmain.cc'"
else
sed 's/^X//' << \SHAR_EOF > 'xmain.cc'
X#include <stream.h>
X#include "x.h"
X
Xmain()
X{
X class Second *x;
X KeyEvent k;
X
X k = Two;
X
X x = new Second;
X x->zap(k);
X cout << "Hello, world\n";
X cout << 12345 << "\n";
X}
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
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