Article View: gnu.g++.bug
Article #253name space polution bug in gcc-2.1
From: Simon J. Gerraty
Date: Tue, 14 Apr 1992 00:11
Date: Tue, 14 Apr 1992 00:11
65 lines
2202 bytes
2202 bytes
The following code demonstrates a problem that appeared while
trying to build groff-1.5 with gcc-2.1 on a Bull DPX/2.
The tests below were run with gcc-2.1 on a sun4c - which gets
the same result (eliminating the possibility that a bug in my
gcc port to the DPX/2 is the problem)
The struct foo contains a member declared as "struct proc
*pfoo". After which it is not possible to use the name "proc" as
a member in a struct. Of course you can subst any name you like
for "proc" and get the same result. Without the struct foo
definition, the module compiles cleanly.
I'm reluctant to believe that this could be a "feature" of C++
as that would mean that it is impossible to write portable code.
Script started on Tue Apr 7 15:40:03 1992
/tmp
<sjg@sun0:1>$ cat foo2.cc
#ifndef FOO
struct foo
{
struct proc *pfoo;
};
#endif
class S
{
int i;
public:
int f(char *cp);
int cf(int index);
};
int S::f(char *cp) { return (i = strlen(cp)); }
int S::cf(int index)
{
struct P
{
char *str;
int (S::*proc)(char *);
};
static struct P Ps[] =
{
"0", &S::f,
"1", &S::f
};
return (this->*(Ps[index].proc))("hi");
}
<sjg@sun0:2>$ gcc -DFOO -c foo2.cc
<sjg@sun0:3>$ gcc -c foo2.cc
foo2.cc: In method `int S::cf (int)':
foo2.cc:30: initialization between incompatible pointer types
foo2.cc:30: initialization between incompatible pointer types
foo2.cc:31: structure has no member named `proc'
foo2.cc:32: warning: control reaches end of non-void function
<sjg@sun0:4>$ exit
script done on Tue Apr 7 15:41:42 1992
Simon J. Gerraty <sjg@melb.bull.oz.au> (work)
<sjg@zen.void.oz.au> (home)
#include <disclaimer> /* imagine something *very* witty here */
Technical Details
Message-ID:
<199204130411.AA18686@sun0.melb.bull.oz.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!melb.bull.oz.AU!sjgShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!melb.bull.oz.AU!sjg From: sjg@melb.bull.oz.AU (Simon J. Gerraty) Subject: name space polution bug in gcc-2.1 Message-ID: <199204130411.AA18686@sun0.melb.bull.oz.au> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 14 Apr 1992 00:11:37 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 66