Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Code Inspection - ASSERT vs. range-based for

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
khb Posted - Sep 12 2018 : 3:43:36 PM
Code Inspection seems to ignore for-loops for range-based-for conversions if an ASSERT() is in the loop (see 1. loop in the following image). If I comment out the ASSERT() line, then the range-based-for conversion is available (2. loop). If I convert the code manually, it compiles (3. loop).



Is this a bug or is this intended?

I'm using VAX 2283, VS 2012, Windows 7.

Code for copy/pasting:
#include <vector>
#include <afx.h>

void test()
{
    struct _s { int a; };
    std::vector<_s> v;
    int x = 0;

    for(auto it = v.begin(); it != v.end(); it++)
    {
        ASSERT(it->a != 0);
        x += it->a;
    }
}
Kind regards,
Marcus
1   L A T E S T    R E P L I E S    (Newest First)
accord Posted - Sep 12 2018 : 11:03:53 PM
I was able to reproduce the problem here. Thank you for the clear description and the code sample.

I've put in a bug report for this:

case=119211

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000