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

Compiler warning level ?

Florian_L_1
Beginner
492 Views

Hello there,

I'd like to have the Compiler warning me for the following things:

uninitialized variables

conversions between different datatypes with possible data loss ( float flTest = 1.2225f; int iTest = flTest; )

 

How would I go about that ? Is there a specific Switch I will need to set ?

Thanks in advance!

0 Kudos
2 Replies
Judith_W_Intel
Employee
492 Views

 

For the first warning on Linux you should use the -Wuninitialized flag and on Windows the diagnostic comes out as a warning by default, i.e.:

!% cat warning.c

int main() {
  float flTest = 1.2225f;
  int iTest = flTest;
  int i;
  i++;
  return 0;
}

!% icl -c warning.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Versi
on Mainline Beta Build x
Built Sep 15 2016 11:01:53 by jward4 on JWARD4-DESK1 in D:/workspaces/cfe/dev
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

warning.c
warning.c(6): warning #592: variable "i" is used before its value is set
    i++;
    ^

!%

We do not have a diagnostic for the int to float conversion. I will enter a request for that. Linux has a -Wfloat-conversion switch but we don't support that yet. I will submit a request for that.

 

0 Kudos
Judith_W_Intel
Employee
492 Views

 

I submitted DPD200415464    in our internal bugs database for a warning on the int to float conversion.

thanks for the suggestion.

Judy

0 Kudos
Reply