1

With the most recent 3.3 update, Android Studio seems to have a very annoying bug giving false warnings in C/C++ codes.

enter image description here

As you can see in the image above, the IDE signals warnings on every bit operation incorporating an immediate value even if it's a positive number.

The only way getting rid of this annoyance is to "typecast" the immediate values to uint32_t which would be even more annoying.

Is there any option to suppress this kind of warnings in Android Studio? I do tons of bit operations in my codes, and it annoys the hell out of me right now.

Or it could be clang's fault, assuming any immediate value to be a signed one by default. Are there compiler options to change it?

pablo285
  • 2,460
  • 4
  • 14
  • 38
Jake 'Alquimista' LEE
  • 6,197
  • 2
  • 17
  • 25

2 Answers2

3

Would have commented on your original post but I don't have the rep. This is not a false warning as the 3 in your original code is in fact a signed integer literal. All integers literals are signed by default in C/C++. To create an unsigned literal you need to add a U suffix (eg. 3u or 3U). There's no need to use a cast to do so.

2

From Android Studio release notes:

Clang-Tidy Support for C++ - Android Studio now has support for Clang-Tidy for C++ static code analysis. Similar to the current lint support for Java and Kotlin in Android Studio, Clang-Tidy helps those who have C++ in their Android app identify common coding errors and bugs. Enable the inspection by going to Settings → Editor → Inspections (Preference → Editor → Inspections for MacOS) . Learn more.

So you can disable it from:

Preferences->Editor->Inspections->General->Clang-tidy

Bonus: You can find the list of Clang-Tidy options if you want to chose from: http://clang.llvm.org/extra/clang-tidy/#using-clang-tidy

Mosbah
  • 1,347
  • 1
  • 14
  • 28
  • 1
    It seems to be the `hicpp-signed-bitwise` option that has been causing all the headache. I don't object compilers giving warnings on signed bitwise operations, but I find it really stupid mangling with positive immediate values. Could you tell me how to disable this particular option individually instead of disabling `clang-tidy` altogether? I tried to put `-hicpp-signed-bitwise` in the option list to no avail (it gets removed when reopened), and configuring via the dialogue box, I don't know what value to put. (neither 0 nor "Off" works) – Jake 'Alquimista' LEE Jan 25 '19 at 10:14