No compilation error with wrong data type

Alexandre Oliva oliva@dcc.unicamp.br
Wed Mar 31 23:54:00 GMT 1999


On Mar 28, 1999, "Aki Niimura" <akineko@worldnet.att.net> wrote:

> Passing 'int' to test() which expects 'Test &w' generates error.

Correct, because we can't bind a non-const reference to a temporary
that would be created with the constructor Test(int).

> Passing 'int' to testConst() which expects 'const Test &w' generates
> no error at all.

Yup; since the reference is const, a temporary can be used.

> However, passing 'int' to test2Const() which expects 'const Test2 &w'
> generate error. 

That's because there's no constructor Test2(int).

Thanks for your report.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Brasil
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,egcs.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists




More information about the Gcc-bugs mailing list