June 23, 2006 Possible implicit type conversion bug with arithmetic op= | ||||
---|---|---|---|---|
| ||||
Try this: int x = 4.5; It fails because you can't implicitly convert a floating point type to an int. Similarly: x = x + 4.5; Also fails. But: x += 4.5; Works, and 4.5 is implicitly converted to an int. This happens with +=, -=, *=, /=, and %=. The bitwise op= (&=, |=, <<=, >>= and >>>=) all issue errors because 4.5 is not integral. I'm 99% sure this is a bug. If so, I'll bugzilla it. |
June 26, 2006 Re: Possible implicit type conversion bug with arithmetic op= | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > Try this: > > int x = 4.5; > > It fails because you can't implicitly convert a floating point type to an int. > > Similarly: > > x = x + 4.5; > > Also fails. > > But: > > x += 4.5; > > Works, and 4.5 is implicitly converted to an int. > > This happens with +=, -=, *=, /=, and %=. The bitwise op= (&=, |=, <<=, >>= and >>>=) all issue errors because 4.5 is not integral. > > I'm 99% sure this is a bug. If so, I'll bugzilla it. > > Does seem like a bug to me. Do report it. -- Bruno Medeiros - CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D |
Copyright © 1999-2021 by the D Language Foundation