March 16, 2007 Compiler doesn't do type conversion of operator?: operands | ||||
---|---|---|---|---|
| ||||
Hi, here's another bug affecting wxWidgets development version: if the types of operator?:'s operands differ, the compiler doesn't try to convert them to a common type. Interestingly enough, it *does* do conversion in some cases (i.e. is already better than BCC5.5, which never converts), but not in others. Again, this is with the latest stable as well as 8.50 beta versions. The following code demonstrates it: -------------- struct wxCStrData { wxCStrData(char *buf) {} operator const char*() const { return "x"; } }; void foo(int n) { wxCStrData c("x"); const char *x = (n==1) ? c : "bar"; } -------------- The error given by DMC ("dmc test.cpp") is: const char *x = (n==1) ? c : "bar"; ^ dmc_ternary_operator.cpp(10) : Error: illegal operand types Had: wxCStrData and: char const * --- errorlevel 1 The code compiles with all other compilers supported by wx (except BCC5.5, which has really touchy operator?:) as well as Comeau in strict mode. Regards, Vaclav |
March 18, 2007 Re: Compiler doesn't do type conversion of operator?: operands | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vaclav Slavik | Thanks for the reports, I'll take care of them. |
Copyright © 1999-2021 by the D Language Foundation