Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Code Inspection - ASSERT vs. range-based for
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

khb
Tomato Guru

Germany
337 Posts

Posted - Sep 12 2018 :  3:43:36 PM  Show Profile  Reply with Quote
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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Sep 12 2018 :  11:03:53 PM  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000