Article View: gnu.g++.bug
Article #4161.35.0 bugs
From: Chris Thewalt
Date: Wed, 13 Sep 1989 19:21
Date: Wed, 13 Sep 1989 19:21
93 lines
2830 bytes
2830 bytes
I attempted to post this last week and it never appeared, so here it is
again. I have 2 apparent bugs, one involving const definition and the
other allowing access of a private member without error.
BUG 1:
#############################################################################
Const declarations are allowed in header files, but when I include
the header file shown below, actual definition takes place for variable "a"
in each .cc file, resulting in "_a is multiply defined" errors at link time.
Details:
Microvax II running Ultrix 2.2
g++ version 1.35.0
foo.h:
------
const int a = 1;
foo1.cc:
--------
#include "foo.h"
int x = a;
foo2.cc:
--------
#include "foo.h"
int y = a;
BUG 2
#############################################################################
In the function shown below, a private member of Class2 (c2.flag) is
accessed without error even though the function is not a friend of Class2.
Details:
Microvax II running Ultrix 2.2
g++ version 1.35.0
Compile log(lines folded by me):
g++ version 1.35.0
/usr/misc/.gnu/lib/compilers/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ \
-D__cplusplus -Dvax -Dunix -D__vax__ -D__unix__ foo.cc /tmp/cc001531.cpp
GNU CPP version 1.35
/usr/misc/.gnu/lib/compilers/gcc-cc1plus /tmp/cc001531.cpp -quiet -dumpbase \
foo.cc -noreg -version -o /tmp/cc001531.s
GNU C++ version 1.35.0 (vax) compiled by GNU C version 1.35.
as /tmp/cc001531.s -o foo.o
----------------------------------------------------------------------------
foo.cc:
-------
#include "foo.h"
Class1& operator*(Class1& c1, Class2& c2)
{
if(c1.flag != c2.flag) // c2.flag should not be accessible
;
}
----------------------------------------------------------------------------
foo.h:
------
// #include <stream.h>
class Class2 {
int flag;
public:
Class2();
~Class2();
friend Class2& operator*(double, Class2&);
friend Class2& operator*(Class2&, double );
};
class Class1 {
int flag;
public:
Class1();
~Class1();
friend Class1& operator*(Class1&, Class2&);
};
---- Chris thewalt@ce.cmu.edu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Christopher Robin Thewalt These opinions are not necessarily
thewalt@ce.cmu.edu shared by my employer...
Carnegie Mellon University
Technical Details
Message-ID:
<6138@pt.cs.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!RITZ.CIVE.CMU.EDU!thewaltShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!RITZ.CIVE.CMU.EDU!thewalt From: thewalt@RITZ.CIVE.CMU.EDU (Chris Thewalt) Newsgroups: gnu.g++.bug Subject: 1.35.0 bugs Keywords: const, friend Message-ID: <6138@pt.cs.cmu.edu> Date: 13 Sep 89 19:21:11 GMT Reply-To: thewalt@RITZ.CIVE.CMU.EDU (Chris Thewalt) Organization: Carnegie Mellon University, Pittsburgh, PA Lines: 93