[Development] QStringLiteral is broken(ish) on MSVC (compiler bug?)

NIkolai Marchenko enmarantispam at gmail.com
Thu Mar 14 21:54:29 CET 2019

I've posted about this issue (I think) on slack a bit earlier, see

On Thu, Mar 14, 2019 at 11:51 PM Matthew Woehlke <mwoehlke.floss at gmail.com>

> While working on some modernization of my application — in particular,
> converting some UTF-8 literals to use QStringLiteral — I noticed a
> concerning compiler warning:
>   warning C4566: character represented by universal-character-name
>   '\uXXXX' cannot be represented in the current code page (1252)
> After doing some testing, it turns out that, given code like
> QStringLiteral("\u269E \U0001f387 \u269F"), MSVC is indeed butchering
> the string.
> Further investigation shows that the problem seems to be with the
> implementation of QStringLiteral. In particular, it appears that the
> preprocessor initially sees just the raw string literal without the 'u'
> prefix, butchers it, then later "promotes" it to a UTF-16 literal, but
> by then the damage has been done.
> While this absolutely feels like a compiler bug, it's an *awful* big
> gotcha that probably should be documented. Also, is there anything that
> Qt can do to work around it? (I know these sorts of macro expansions can
> be tricksy...)
> Note: and the *local* work-around is apparently to include the 'u'
> prefix on my own literal; apparently doubling it (`uu"stuff"`) is okay.
> --
> Matthew
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190314/60243e52/attachment.html>

More information about the Development mailing list