Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Dave Gillespie
Tue, 26 Jan 1993 02:30
Gcc 2.1 scoping bug
Author: 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
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