:? ??
Joe Buck
Joe.Buck@synopsys.com
Tue Mar 19 09:21:00 GMT 2002
> Hi
> I have just been fixing several files in KDE 3.0 so they compile using Sun's
> native compiler. The most frequent fix I had to make was the following case:
>
> for some QString a:
> QString b = (exp) ? "xyz" : a;
>
> Now the sun compiler insisted the two types in ?: needs to be identical. Now
> I am wondering what on earth gcc is doing?
If Sun issues a message claiming that the types of the second and third
arguments need to be identical, this is wrong.
The ISO C++ standard specifies the behavior of this operation. Without
seeing the set of operations that the QString class declares, I can't tell
if there is a bug or not, or which compiler has the bug.
> Is it doing:
> (exp) ? QString("xyz") : a
> or
> QString(exp ? "xyz" : (const char*)a);
Does QString define an operator const char*() ? The std::string class
avoids this problem by making the user invoke a specific function to
convert to const char*.
More information about the Gcc
mailing list