home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / gcc / bug / 3250 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.3 KB  |  72 lines

  1. Path: 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
  2. From: daveg@thymus.synaptics.COM (Dave Gillespie)
  3. Newsgroups: gnu.gcc.bug
  4. Subject: Gcc 2.1 scoping bug
  5. Date: 25 Jan 1993 21:30:02 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 58
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-gcc@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301260059.AA06190@thymus.synaptics>
  12. Reply-To: daveg@synaptics.com
  13.  
  14. I've found an inconsistency with gcc 2.1 vs. the ARM concerning C++
  15. scoping rules.  Briefly, the ARM states (10.4) that member names
  16. always shadow global names inside a member function, but this does
  17. not seem to be the case when a member function shadows a global
  18. type name.
  19.  
  20. % gcc -v bug1.cxx
  21. Reading specs from /packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/specs
  22. gcc version 2.1
  23.  /packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/cpp -lang-c++ -v -I/syn/inc
  24. lude -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__spa
  25. rc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug1.cxx /usr/tmp/cca06131.
  26. i
  27. GNU CPP version 2.1 (sparc)
  28.  /packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/cc1plus /usr/tmp/cca06131.i
  29.  -quiet -dumpbase bug1.cc -version -o /usr/tmp/cca06131.s
  30. GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
  31.  /packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1.2/2.1/as -o bug1.o /usr/tmp/cca06
  32. 131.s
  33.  ld -e start -dc -dp /lib/crt0.o -L/packages/lib/sun4/gcc-lib/sparc-sun-sunos4.1
  34. .2/2.1/ -L/packages/lib/sun4/ bug1.o -lgcc -lc -lgcc
  35. % a.out
  36. range::range
  37. % cat bug1.cxx
  38. #include <stdio.h>
  39.  
  40. class range {
  41. public:
  42.   range() { printf("range::range\n"); }
  43. };
  44.  
  45. class image {
  46. public:
  47.   void range() { printf("image::range\n"); }
  48.   void foo() { range(); }
  49. };
  50.  
  51. main()
  52. {
  53.   image I;
  54.   I.foo();
  55. }
  56.  
  57. %
  58.  
  59. Sun's cfront-based compiler produces the output "image::range" on
  60. this program.  Gcc seems to exhibit this bug whether or not "foo"
  61. is inline, and whether or not the two "range"s take any arguments
  62. (as long as the arguments are the same in all three places).
  63.  
  64. Interestingly, if an "int" argument is added to the "range" function
  65. and the "range" call, but *not* to the "range" constructor, gcc
  66. agrees with cfront.  This also seems suspicious, as C++ scoping
  67. and overload resolution are supposed to work independently.
  68.  
  69. Thanks,
  70.                                 -- Dave
  71.  
  72.