gcc bug

Matthias Meixner meixner@rbg.informatik.tu-darmstadt.de
Wed Apr 5 06:57:00 GMT 2000


Hallo,

I think I have found a bug in the C++ part of gcc (gcc version 2.96 20000405
(experimental)):

Compiling

struct A {

   int x;
   
   operator int &() { return x; }
   operator const int &() { return x; }
   operator const int &() const { return x; }
};

main()
{
   A a={2};

   int x=a;
}

gives the error message:

t5.cxx: In function `int main ()':
t5.cxx:15: cannot convert `A' to `int' in initialization

Earlier version 2.95.2 reports:

t5.cxx: In function `int main()':
t5.cxx:15: conversion from `A' to `int' is ambiguous
t5.cxx:6: candidates are: A::operator int &()
t5.cxx:7:                 A::operator const int &()
t5.cxx:8:                 A::operator const int &() const

Regards,

	Matthias Meixner

-- 
Matthias Meixner                   meixner@rbg.informatik.tu-darmstadt.de
Technische Universität Darmstadt
Rechnerbetriebsgruppe                          Telefon (+49) 6151 16 6670
Wilhelminenstraße 7, D-64283 Darmstadt, Germany    Fax (+49) 6151 16 4701


More information about the Gcc-bugs mailing list