[Qt-interest] Undefined behavior in QString::toStdWString() ?

Scott Aron Bloom Scott.Bloom at sabgroup.com
Fri Dec 12 09:57:07 CET 2008


> However, according to the Forward Iterator requirements of the C++
> standard (24.1.3, Table 74), the unary operator* has a precondition
that
> its operand is dereferenceable, and states that
>    "a == b implies that *a == *b"
> 
> So by this definition, dereferencing begin() on an empty string should
> be just as much of a no-no as dereferencing end(), is it not? I know
> that we probably won't get into trouble as long as we don't actually
> assign to it, but UB is UB...

[Scott Aron Bloom] 
However if the class you are operating on has overloaded opereator *,
which std::string does, you have to look into the definition of the
operator for that class.

Scott




More information about the Qt-interest-old mailing list