This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: :? ??
- From: Allan Sandfeld Jensen <snowwolf at one2one-networks dot com>
- To: Joe Buck <Joe dot Buck at synopsys dot com>,matzmich at cs dot tu-berlin dot de (Michael Matz)
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 19 Mar 2002 23:35:59 +0100
- Subject: Re: :? ??
- References: <200203191817.KAA10591@atrus.synopsys.com>
On Tuesday 19 March 2002 19:17, Joe Buck wrote:
> > On Tue, 19 Mar 2002, Joe Buck wrote:
> > > > Is it doing:
> > > > (exp) ? QString("xyz") : a
> > > > or
> > > > QString(exp ? "xyz" : (const char*)a);
> > >
> > > Does QString define an operator const char*() ?
> >
> > Under certain circumstances. In "strict" mode it doesn't.
It does unless QT_NO_ASCII_CAST flag is set, in fact no part of kde would
compile with this flag since at least the implicit constructor from const
char* is too widely used.
> If there is both an operator const char*() and a constructor that takes
> a const char* argument that is not marked explicit, then
>
> QString qstring_var;
> ...
> QString fred = cond ? "foo" : qstring_var;
>
> is ambiguous, otherwise not.
Well in that case it is ambiguous, they are both defined. Plus operator=,
the full monty :)
( I didnt know about the explicit mark, but they dont use it anyway )
Sun's compiler might be a little too touchy about type-casting, but in this
case it is right.
I have never seen any warnings from gcc, so it should be a problem in 2.95,
3.0 and 3.1.
`Allan