[Development] QtCS: Notes from Modern C++ session
Thiago Macieira
thiago.macieira at intel.com
Tue Dec 1 17:04:39 CET 2015
On Tuesday 01 December 2015 10:00:29 Marc Mutz wrote:
> On Tuesday 16 June 2015 22:31:51 Thiago Macieira wrote:
> > MSVC 2012 and 2013 have a parsing bug with them, so you need to
> >
> > compile your code with one of those two versions if you're introducing new
> > range fors.
>
> Do you have specifics here? IIRC, it was something like
>
> while (...)
> for (... : .... ) {
> }
>
> which is excluded by our coding standard (missing braces), so it can never
> happen.
It fails to compile tst_compiler.cpp's cxx11_range_for.
for (int i : l)
QCOMPARE(i, 1);
The reduced testcase, which I sent to Microsoft but can no longer find, is when
you have a while inside a for. I don't remember whether the braces are
required or must be absent or not.
This one is reported to still have a problem with 2015:
https://connect.microsoft.com/VisualStudio/feedback/details/1513773/cannot-use-lambda-in-the-single-statement-of-the-range-for-loop
There's another one with try/catch, but I can't find my log in to read the
details:
https://connect.microsoft.com/VisualStudio/feedbackdetail/view/874705
See also this still open report:
https://connect.microsoft.com/VisualStudio/feedback/details/2036654/c-compiler-bug-range-based-for
for (const auto &outer : v)
for (const auto &item : outer)
do {} while (false);
Anyway, the rule for Qt 5.7 is that you can use range fors, as long as you
first compile your code with VS 2012 or 2013 due to their various parsing bugs.
Don't submit to the CI until you have tested yourself or someone has on your
behalf.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list