Article View: gnu.gcc.bug
Article #1659Gcc 2.1 scoping bug
From: Dave Gillespie
Date: Tue, 26 Jan 1993 02:30
Date: Tue, 26 Jan 1993 02:30
57 lines
2452 bytes
2452 bytes
I've found an inconsistency with gcc 2.1 vs. the ARM concerning C++
scoping rules. Briefly, the ARM states (10.4) that member names
always shadow global names inside a member function, but this does
not seem to be the case when a member function shadows a global
type name.
% gcc -v bug1.cxx
Reading specs from /packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/specs
gcc version 2.1
/packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/cpp -lang-c++ -v -I/syn/inc
lude -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__spa
rc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug1.cxx /usr/tmp/cca06131.
i
GNU CPP version 2.1 (sparc)
/packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/cc1plus /usr/tmp/cca06131.i
-quiet -dumpbase bug1.cc -version -o /usr/tmp/cca06131.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
/packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/as -o bug1.o /usr/tmp/cca06
131.s
ld -e start -dc -dp /lib/crt0.o -L/packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1
.2/2.1/ -L/packages/lib/sun4/ bug1.o -lgcc -lc -lgcc
% a.out
range::range
% cat bug1.cxx
#include <stdio.h>
class range {
public:
range() { printf("range::range\n"); }
};
class image {
public:
void range() { printf("image::range\n"); }
void foo() { range(); }
};
main()
{
image I;
I.foo();
}
%
Sun's cfront-based compiler produces the output "image::range" on
this program. Gcc seems to exhibit this bug whether or not "foo"
is inline, and whether or not the two "range"s take any arguments
(as long as the arguments are the same in all three places).
Interestingly, if an "int" argument is added to the "range" function
and the "range" call, but *not* to the "range" constructor, gcc
agrees with cfront. This also seems suspicious, as C++ scoping
and overload resolution are supposed to work independently.
Thanks,
-- Dave
Technical Details
Message-ID:
<9301260059.AA06190@thymus.synaptics>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!thymus.synaptics.COM!davegShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!thymus.synaptics.COM!daveg From: daveg@thymus.synaptics.COM (Dave Gillespie) Newsgroups: gnu.gcc.bug Subject: Gcc 2.1 scoping bug Date: 25 Jan 1993 21:30:02 -0500 Organization: GNUs Not Usenet Lines: 58 Sender: daemon@cis.ohio-state.edu Approved: bug-gcc@prep.ai.mit.edu Distribution: gnu Message-ID: <9301260059.AA06190@thymus.synaptics> Reply-To: daveg@synaptics.com