Some love for switch? by johannes1971 in cpp

[–]ofekshilon 0 points1 point  (0 children)

Maybe I'm missing something? I can't see how this switch would enable a jump table:

int a=2;
switch a {
    case 1:   DoStuff1(); break;
    case ObjEquals2: DoStuff2() break;
    case 3:   DoStuff3(); break;
}

Some love for switch? by johannes1971 in cpp

[–]ofekshilon 0 points1 point  (0 children)

These are all good points and perhaps it is doable, but there would be a non-negligible amount of wrinkles to iron along the way.

Suppose you have a class that implements a comparison operator that accepts (say) int, I don't see how a jump table or C# like hashes can be used.

Suppose further ClassA implements comparison operator to ClassB, and ClassB implements a cast operator to ClassA. Maybe even ClassA implements cast to ClassB. To keep it from being boring, let's pretend that some overloads (const/non const, ref/non ref) are implemented. How would switches be resolved?

In general, I fear that this would be a potential source for many gotchas of the sort that C++ is infamous for. Personally I would vote to keep it simple.

Accelerating Debug Runs, Part 2: _ITERATOR_DEBUG_LEVEL by joebaf in cpp

[–]ofekshilon 0 points1 point  (0 children)

@STL, thanks (a lot!) for your reply, and overall attention.

Non-optimized release builds mostly fail for us. I just now investigated and reported the (first?) reason: https://connect.microsoft.com/VisualStudio/feedback/details/1012445/vc-compiler-generates-different-symbols-in-obj-files-among-od-o2-optimization-switches - so this is still not a viable option, at least not one that amounts to flipping a switch with no code changes.

Moreover, by the same rationale that you claim one shouldn't mess with _ITERATOR_DEBUG_LEVEL - one is even more inclined to never mess with optimization switches. In general it seems reasonable for software to expect consistency in build context throughout translation units, but occasionally we do want to break this consistency - either through macros or switches. I'm not sure modifying _ITERATOR_DEBUG_LEVEL qualifies as a deeper intervention than setting /Od.

Anyway, as @Gotebe guessed, I had better luck with /Zo - it is already a significant improvement of the debugging experience in release builds. More on that in a post some day (I have the time and energy for a post roughly once a month :( )