Some VS2022 IntelliSense Warnings

Hi all,

Visual Studio 2022 points out quite a few IntelliSense warnings in the JUCE code whenever I build. To be clear, they’re not actual compiler/linker errors/warnings, but rather the VS IntelliSense feature trying to be clever by pointing out code that doesn’t necessarily follow best practice.

I’m sure most (maybe even all) of it is benign, but it includes some eyebrow raising ones. For example, there are lots of these:

C26495|Variable 'xxx' is uninitialized. Always initialize a member variable (type.6).

Thought it might be helpful to post them here just in case. Note that the line numbers may not always match, since we’ve customized some of our JUCE code. That said, none of the warnings are in our customized code AFAIK.

So here you go JUCE guys. Feel free to fix or ignore as you see fit!

Thanks,
Ben

JUCE 7.0.2 VS2022 IntelliSense Warnings 20-09-2022.txt (53.1 KB)

I wouldn’t pay too much attention to IntelliSense. What does your compiler say?

IntelliSense may not even be aware of your compiler.

C26495:

I agree that all-warnings-are-errors, but I think compiler-warnings-and-errors-trump-3rd-party-tooling is also true. The customer doesn’t run IntelliSense build products … :stuck_out_tongue_winking_eye:

This was just intended as an FYI, because there might be a few legit bugs among the bogus stuff.

IntelliSense is indeed a separate entity to the VS compiler/linker. It has a ‘code linter’ feature to help C++ devs find and fix code defects as they write it, rather than doing it during a build. It catches a bunch of common coding errors that the compiler might otherwise miss, and that are at least worth sanity checking IMO.

Examples:
Arithmetic Overflow
Integer Division Assigned to Floating Point
Logical/Bitwise Mismatch
Assignment/Equality Mismatch
Accidental Copy
Uninitialized Local

What’s more, it’s now enabled by default in VS2022. So it’s worth paying attention IMO. As an occasional sanity check if nothing else.

See:
IntelliSense Code Linter for C++ - C++ Team Blog (slightly out of date, but still relevant)

Edit: FWIW, we’ve already caught a bunch of legit ‘accidental copy’ issues (no build errors or warnings) in our code since we updated to VS2022.

Edit 2: The warnings it comes up with seem to be, for the most part, exactly the same ones that static code analysis finds during a build too. So yes, while they may be numerous and annoying, and benign in many cases, I think it’s sensible to take a peek once in a while.

1 Like