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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cse.ucsc.EDU!dlong
  2. From: dlong@cse.ucsc.EDU (Dean R. E. Long)
  3. Newsgroups: gnu.g++.bug
  4. Subject: "trivial conversion" bug
  5. Date: 25 Jan 1993 20:05:03 -0500
  6. Organization: University of California, Santa Cruz (CE/CIS Boards)
  7. Lines: 53
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <1jr08eINNh2u@darkstar.UCSC.EDU>
  12.  
  13. In this example, should not the trivial conversion (const T --> const T &)
  14. be applied before the user-defined conversion?
  15.  
  16. --
  17. arapaho /tmp [61] % cat a.c
  18. #include <stream.h>
  19.  
  20. class A {
  21. public:
  22.     A(int)      {}
  23.     operator const A & (void) const
  24.     {
  25.         cout << "Converted to (const A &) !\n";
  26.         return *this;
  27.     }
  28.     operator == (const A &a) const
  29.     {
  30.         return 1;
  31.     }
  32. };
  33.  
  34. main()
  35. {
  36.     const A a = 0, b = 0;
  37.  
  38.     return a == b;
  39. }
  40. arapaho /tmp [62] % g++ -v a.c
  41. Reading specs from /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/specs
  42. gcc version 2.3.3
  43.  /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/cpp -lang-c++ -v -undef -
  44. D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun_
  45. _ -D__unix__ -D__sparc -D__sun -D__unix a.c /usr/tmp/cca19255.i
  46. GNU CPP version 2.3.3 (sparc)
  47.  /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/cc1plus /usr/tmp/cca19255
  48. .i -quiet -dumpbase a.cc -version -o /usr/tmp/cca19255.s
  49. GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
  50.  as -o /usr/tmp/cca192551.o /usr/tmp/cca19255.s
  51.  /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/ld -e start -dc -dp /lib/
  52. crt0.o -L/usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3 -L/usr/local/gnu/
  53. lib /usr/tmp/cca192551.o -lg++ -lgcc -lc -lgcc
  54. arapaho /tmp [63] % a.out
  55. Converted to (const A &) !
  56. Converted to (const A &) !
  57. Converted to (const A &) !
  58. Converted to (const A &) !
  59. Converted to (const A &) !
  60. Converted to (const A &) !
  61. Converted to (const A &) !
  62. Converted to (const A &) !
  63. Converted to (const A &) !
  64. [repeated forever...]
  65.  
  66.