Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

-Wtype-limits support

Sangmin_S_
Beginner
509 Views

Hi,

I used the same compiler flags of gcc when using icc. So, when I used -Wall and -Wextra for the below code, I was expecting a warning of pointless comparison (which is always true) from icc. However, I got no warning and it seems -Wtype-limits is not included in -Wall or -Wextra. Actually, -Wextra of gcc enables -Wtype-limits.

#include <stdio.h>

int main()
{
    size_t off = 10;
    if (off >= 0) {
        printf("off=%lu\n", off);
    }
    return 0;
}

If I explicitly use -Wtype-limits, icc generates the warning:
warning.c(6): warning #186: pointless comparison of unsigned integer with zero
      if (off >= 0) {

My question is whether -Wtype-limits is officially supported in the Intel Compiler or not. If so, I also want to know if it is documented somewhere. I could not find any information about -Wtype-limits from the Intel Compiler manual or man page.

Thanks in advance,

Sangmin

0 Kudos
2 Replies
Judith_W_Intel
Employee
509 Views

 

We do not re-document all the -W options ourselves since they are supposed to be compatible with the GNU options. Please look at the GNU man page or online docs. We only document options that are specific to Intel or are intentionally different when used with Intel.

It sounds like the -Wtype-limits option is working as expected (or else you would have gotten a warning from the driver about ignoring an unknown option).

The only problem seems to be that it not included in -Wextra, is that correct? I have submitted a problem report for that as :DPD200357763.

Thanks for letting us know.

Judy

0 Kudos
Sangmin_S_
Beginner
509 Views

Yes, -Wtype-limits flag is currently working in icc but it is not included in -Wextra.

Thanks for the reply.

Sangmin

0 Kudos
Reply