Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!ulysses!allegra!alice!shopiro From: shopiro@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: Bug in automatic type conversion? Summary: One's yours and one's ours Message-ID: <7544@alice.UUCP> Date: 17 Dec 87 02:15:50 GMT References: <5192@columbia.edu> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 44 Posted: Wed Dec 16 21:15:50 1987 In article <5192@columbia.edu>, eppstein@garfield.columbia.edu.UUCP writes: < I want to use automatic conversion of a certain class to strings, but it < seems to screw up other stuff around it. This is in < #ident "@(#)cfront:CC 1.11" < and the error messages generated in the following program are: < < CC test.c: < "test.c", line 23: error: two initializers for baz() argument x < "test.c", line 23: error: bad initializer type const_char_star < for x ( int expected) < 2 errors < < The program itself: < < ... < < int baz(int = -1); < ... < int baz(int x = -1) < { < return x; < } < -- < David Eppstein eppstein@garfield.columbia.edu Columbia U. Computer Science Of the two error messages you got, one should be there. A default initializer may only appear once, in the declaration of a function. The reason is that if two initializers were given for the same argument, (one in the declaration and one in the definition) and they had different values, we would interpret that as an error. But it is hard for the cfront to check whether two expressions have the same value, since certain constant expressions (e.g., floating point) are evaluated by the underlying C compiler. So we only allow one initializer. The other error message should not be there, and it isn't in the latest internal version of cfront. I don't know when that version will make it out the door, but I hope it will be soon. -- Jonathan Shopiro AT&T Bell Laboratories, Murray Hill, NJ 07974 research!shopiro (201) 582-4179